To add text to a PDF document, do the following:
- Create a PDFXpress object and initialize it.
- Create a PdfDocument object from an existing PDF file.
- Create an AddTextOptions object.
- Set the AddTextOptions:
- FontSize – we chose 14
- FontWeight – we chose bold
- Call AddText() on the PdfDocument object.
- Create a SaveOptions object.
- Call Save() on the PdfDocument object to save the PDF with text added.
VB6 Example | ![]() |
---|---|
Private Sub Form_Load() Dim pdf As New PdfXpress pdf.InitializePaths "C:\Users\Public\Documents\Accusoft\PDFXpress\V5.0\Support\Font", _ "C:\Users\Public\Documents\Accusoft\PDFXpress\V5.0\Support\CMap" Dim doc As New PdfDocument doc.SetParentControl pdf doc.OpenDocument "C:\myfile.pdf", "" Dim options As New AddTextOptions options.FontSize = 14 options.FontWeight = PDF_FontWeight_Bold doc.AddText 0, options, "Hello World!" Dim so As New SaveOptions so.FileName = "C:\text.pdf" so.Linearized = True so.Overwrite = True doc.SaveDocument so Set so = Nothing Set options = Nothing Set doc = Nothing pdf.Terminate Set pdf = Nothing End Sub |