Accusoft.PdfXpress5.Net
Add Text to a PDF document
Send Feedback
PDF Xpress 5 for .NET - User Guide > How To > Modify PDF Document Content > Add Text to a PDF document

Glossary Item Box

To add text to a PDF document, do the following:

  1. Create a PDFXpress object and initialize it.
  2. Create a Document object from an existing PDF file.
  3. Create an AddTextOptions object.
  4. Set the AddTextOptions:
  5. Call AddText() on the Document object.
  6. Create a SaveOptions object.
  7. Call Save() on the Document object to save the PDF with text added.
C# Example Copy Code
using System;
using Accusoft.PdfXpressSdk;
namespace Text
{
    class AddText
    {
        static void Main(string[] args)
        {
            using (PdfXpress pdf = new PdfXpress())
            {
                pdf.Initialize(@"C:\Users\Public\Documents\Accusoft\PDFXpress\v5.0\Support\Font",
                               @"C:\Users\Public\Documents\Accusoft\PDFXpress\v5.0\Support\CMap");
                using (Document doc = new Document(pdf, "C:\\myfile.pdf"))
                {
                    AddTextOptions options = new AddTextOptions();
                    options.FontSize = 14;
                    options.FontWeight = FontWeight.Bold;
                    doc.AddText(options, 0, "Hello world!");
                    //set the save options
                    SaveOptions so = new SaveOptions();
                    so.Filename = "C:\\text.pdf";
                    so.Overwrite = true;
                    so.Linearized = true;
                    //save the document
                    doc.Save(so);
                }
            }
        }
    }
}
©2012. Accusoft Corporation. All Rights Reserved.