Accusoft.PdfXpress7.Net
Add Text to a PDF document

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 System.Drawing;
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\v7.0\Support\Font",
                               @"C:\Users\Public\Documents\Accusoft\PDFXpress\v7.0\Support\CMap");
                using (Document doc = new Document(pdf, "C:\\myfile.pdf"))
                {
                    AddTextOptions options = new AddTextOptions();
                    options.BoundingBox = new RectangleF(40, 300, 200, 100);
                    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);
                }
            }
        }
    }
}

 

 


©2018. Accusoft Corporation. All Rights Reserved.

Send Feedback