Table of Contents
- Getting Started
- EO.Pdf
- Overview
- Installation and Deployment
- Using HTML to PDF
- Using PDF Creator
- Working with Existing PDF Files
- Using in Web Application
- Advanced Topics
- EO.Web
- EO.WebBrowser
- EO.Wpf
- Common Topics
- Reference
Modify PDF Files |
To modify a PDF file, you must load it to a PdfDocument object first, then use any API available to PdfDocument to modify the document.
The following code load a PDF file, append a new page and then save it with a different name:
//Load the file PdfDocument doc = new PdfDocument(pdfFileName); //Append a new page PdfPage page = doc.Pages.Add(); //Render contents on the new page HtmlToPdf.ConvertHtml("Text on the new page.", page); //Save it to a new file doc.Save(newFileName);
You can also modify existing pages. The following code overlays additional text on the first page:
//Load the file PdfDocument doc = new PdfDocument(pdfFileName); //Get the first page PdfPage page = doc.Pages[0]; //Render contents on the page HtmlToPdf.ConvertHtml("Overlay text", page); //Save it to a new file doc.Save(newFileName);