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()