Adding text on an existing PDF

Discussions about PDF management.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Adding text on an existing PDF

Post by Loïc » Fri Jul 29, 2011 10:12 pm

Hello,

Here a snippet to add text on an existing PDF using incremental saving :

Code: Select all

   Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
      Dim oGdPicturePDF As New GdPicturePDF

      oGdPicturePDF.SetLicenseNumber("XXX") 'Replace XXX by a valid demo or commercial key

      If oGdPicturePDF.LoadFromFile("c:\test.pdf", True) = GdPictureStatus.OK Then
         oGdPicturePDF.SelectPage(1) 'Selecting first page
         Dim font_res_name As String = oGdPicturePDF.AddTrueTypeFont("Arial", False, False, False)
         oGdPicturePDF.SetTextMode(PdfTextMode.PdfTextModeFill)
         oGdPicturePDF.SetTextSize(30)
         oGdPicturePDF.SetFillColor(255, 0, 0, 0) 'Using Cyan colour
         oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
         oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
         oGdPicturePDF.DrawText(font_res_name, 1, 1, "Hello World!")
         oGdPicturePDF.SaveToFileInc("c:\test.pdf")
         oGdPicturePDF.CloseDocument()
         MsgBox("Done")
      End If
   End Sub

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: Adding text on an existing PDF

Post by Gabriela » Fri Mar 29, 2019 11:34 pm

Please find the refreshed and updated example in the documentation page for the DrawText() method:

DrawText Method (GdPicturePDF)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest