PDF Xpress for .NET - User Guide > How To > Modify PDF Document Content > Add Text to a PDF document |
To add text to a PDF document, do the following:
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); } } } } } |