Click or drag to resize
Pdf Library for .NET
Modify Existing Pdf Documents

Select.Pdf Library for .NET can be used to load and modify existing pdf documents. The following sample code shows how to load a pdf document from a local file from the disk:

// load pdf file from disk
PdfDocument doc = new PdfDocument(fileName);

The PdfDocument object also provides constructors that can be used to load the pdf document from a stream.

Once a pdf document is loaded, all operations described in this documentation can applied to it: add new pages to the document, remove existing pages, add new elements to new or existing pages, add new pdf templates.

Sample Code

This sample code shows how to use SelectPdf Library for .NET to load an existing document, add a new page to it and a new text element.

// the initial file
string file = Server.MapPath("~/files/doc1.pdf");

// load the pdf document
PdfDocument doc = new PdfDocument(file);

// add a new page to the document
PdfPage page = doc.AddPage();

// create a new pdf font (component standard font)
PdfFont font = doc.AddFont(PdfStandardFont.Helvetica);
font.Size = 20;

// create text element and add it to the new page
PdfTextElement text = new PdfTextElement(100, 100,
    "Sample text added to an existing pdf document.", font);

// save pdf document
doc.Save(Response, false, "Sample.pdf");

// close pdf document
See Also