New PDF Document API
The New PDF Document API is a modern, high-level .NET library built on top of DevExpress PDF infrastructure. It provides a streamlined API for loading, editing, protecting, and saving PDF files using the PdfDocument class from the DevExpress.Docs.Pdf namespace.
Note: The original PDF Document API (PdfDocumentProcessor) remains available and may still be suitable for existing projects or workflows built around its API.
If you depend on functionality currently available in the classic PdfDocumentProcessor API, you may want to review the original PDF Document API demo alongside this newer implementation.
If you depend on functionality currently available in the classic PdfDocumentProcessor API, you may want to review the original PDF Document API demo alongside this newer implementation.
Get Started
Install the DevExpress.Docs.Pdf NuGet package
dotnet add package DevExpress.Docs.PdfCode Example - Encrypt PDF with Password
using DevExpress.Docs.Pdf;
using var pdfDocument = new PdfDocument();
// Add an A4 page to the document
Page page = pdfDocument.Pages.Add(DXPaperKind.A4);
// Add a title
page.AddFragment(new TextFragment {
Text = "Quarterly Sales Report",
Location = new PointF(50, 770),
Font = new TextFont("Arial", TextFontStyle.Bold),
FontSize = 24
});
// Add a paragraph.
page.AddFragment(new TextFragment
{
Text = "This report summarizes sales data " +
"for Q1 2026.",
Location = new PointF(50, 730),
Font = new TextFont("Arial"),
FontSize = 12
});
// Add an image.
DXImage logo = DXImage.FromFile("logo.png");
page.AddFragment(new ImageFragment(logo)
{
Location = new PointF(50, 600),
Size = new SizeF(200, 100)
});
// Save the document.
using (FileStream outputStream =
File.Create("SalesReport.pdf"))
{
pdfDocument.Save(outputStream);
}Code Example - Merge two PDF documents into a Single File
using DevExpress.Docs.Pdf;
using var doc = new PdfDocument();
doc.AppendDocument(docStream1);
doc.AppendDocument(docStream2);
doc.Save(mergedStream);Key Features
The New PDF Document API allows you to manage PDF documents with a clean, modern API surface:
- Load from stream or create empty documents
- Add text, image, and path fragments to pages
- Merge or split files, manage pages
- Add and clear annotations
- Create and fill interactive forms
- Password-protect and encrypt documents
- Redact sensitive content permanently
- Attach files and ZUGFeRD invoices
- Import and export form data (XML, FDF, XFDF)
- Read and update document metadata
- Find and highlight text
- And much more
API Highlights
using DevExpress.Docs.Pdf;
// Load from stream
using var doc = new PdfDocument(stream);
// Access pages – each page exposes Fragments and Annotations
var page = doc.Pages[0];
page.AddTextFragment("Hello World", options);
// Attach a file
doc.Attachments.Add(attachmentStream, "report.pdf");
// Attach a ZUGFeRD invoice
doc.AttachZugferdInvoice(invoiceStream);
// Redact sensitive content
doc.ApplyRedaction(pageIndex, redactionAnnotations);
// Import / export form data
doc.ImportFormData(formDataStream, ExportDataFormat.Xml);
doc.ExportFormData(outputStream, ExportDataFormat.Xml);
// Read metadata
var title = doc.Metadata.Title;
// Save
doc.Save(outputStream);