Loading...

Writing text on the middle of a page of an existing PDF

Support for GdPicturePDF Plugin.

Writing text on the middle of a page of an existing PDF

Postby Loïc » Sat Dec 17, 2011 12:29 pm

Code: Select all
        Dim oGdPicturePDF As New GdPicture.GdPicturePDF
        Dim text As String = "Hello World!"
        Dim textSize As Single = 12
        oGdPicturePDF.LoadFromFile("c:\TWAIN_2_1_Spec.pdf", False)
        Dim pageWidth As Single = oGdPicturePDF.GetPageWidth 'Be careful: this function returns value in PDF points unit
        Dim pageHeight As Single = oGdPicturePDF.GetPageHeight 'Be careful: this function returns value in PDF points unit
        Dim fontResName As String = oGdPicturePDF.AddTrueTypeFont("Arial", False, False, False)
        oGdPicturePDF.SelectPage(1)
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
        oGdPicturePDF.SetTextSize(textSize)
        Dim textWidth As Single = oGdPicturePDF.GetTextWidth(fontResName, textSize, text)
        oGdPicturePDF.DrawText(fontResName, pageWidth / 2 - textWidth / 2, pageHeight / 2, text)
        oGdPicturePDF.SaveToFileInc("c:\newpdf.pdf")
        oGdPicturePDF.CloseDocument()
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4437
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Return to GdPicture PDF Plugin

Who is online

Users browsing this forum: No registered users and 1 guest