Facades API
Facades API
The Facades API provides simplified, task-oriented wrappers around the core
Aspose.PDF FOSS for .NET object model. Each facade class targets a specific
PDF operation — form filling, file concatenation, content editing, or digital
signing — and exposes a BindPdf / Save workflow.
Form filling with the Form facade
Form (in Aspose.Pdf.Facades) binds to an existing PDF and lets you read
or write AcroForm field values without navigating the page tree.
using var form = new Form("input.pdf", "output.pdf");
form.FillField("FirstName", "Alice");
form.FillField("AcceptTerms", "Yes");
form.Save();To read field values:
using var form = new Form("input.pdf");
string name = form.GetField("FirstName");Merging and splitting PDFs with PdfFileEditor
PdfFileEditor concatenates, splits, extracts, and deletes page ranges.
var editor = new PdfFileEditor();
// Concatenate two files
editor.Concatenate("file1.pdf", "file2.pdf", "merged.pdf");
// Extract pages 2-5
editor.Extract("source.pdf", 2, 5, "pages2to5.pdf");
// Split at page 3
editor.SplitFromFirst("source.pdf", 3, "first3.pdf");Editing page content with PdfContentEditor
PdfContentEditor modifies existing page content — add text, replace text,
or attach actions to annotations.
var editor = new PdfContentEditor();
editor.BindPdf("input.pdf");
// Perform content edits
editor.Save("output.pdf");Digital signatures with PdfFileSignature
PdfFileSignature signs PDF documents and verifies existing signatures.
var sig = new PdfFileSignature();
sig.BindPdf("document.pdf");
// Sign or verify
sig.Save("signed.pdf");Page stamping with PdfFileStamp
PdfFileStamp overlays text, images, or other PDF pages as stamps.
var stamp = new PdfFileStamp();
stamp.BindPdf("input.pdf");
// Add stamps
stamp.Save("stamped.pdf");
stamp.Close();Converting pages to images with PdfConverter
PdfConverter renders PDF pages to raster image formats.
var converter = new PdfConverter();
converter.BindPdf("input.pdf");
converter.DoConvert();
// Iterate pages and save imagesTips and Best Practices
- Always call
Close()or useusingto release resources held by facade objects. - Use
BindPdfwith a file path for large files to avoid loading everything into memory at once. - Prefer
TryConcatenateandTryAppendover their non-Try counterparts for graceful error handling. - Facades delegate to the core
Documentmodel internally — switch to the core API when you need fine-grained control. - The
FormEditorfacade allows adding new form fields to an existing PDF, not just filling existing ones.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
Save() produces empty file | BindPdf was not called before save | Always bind a source PDF before calling Save |
| Form field value not written | Field name does not match the PDF’s internal field name | Use Form.FieldNames to list available field names |
| Concatenation fails silently | Input file is encrypted or corrupted | Use TryConcatenate and check the return value |
| Signatures invalid after edit | Content was modified after signing | Sign the document as the final step |
FAQ
What is the difference between Facades and the core Document API?
Facades provide high-level, task-oriented methods (fill a form, merge files).
The core API (Document, Page, Annotation) gives lower-level access to
every PDF object. Facades use the core API internally.
Can I chain multiple facade operations?
Yes. Bind the same source, perform operations, and save once. Or save an intermediate result and re-bind for the next operation.
Does PdfFileEditor support password-protected PDFs?
Yes. Overloads that accept owner/user passwords are available for encrypted files.
API Reference Summary
| Class / Method | Description |
|---|---|
Form | AcroForm facade for reading and writing field values |
Form.FillField | Set a form field value by name |
Form.GetField | Read a form field value by name |
FormEditor | Add or modify form fields in an existing PDF |
PdfFileEditor | Merge, split, extract, and delete PDF page ranges |
PdfFileEditor.Concatenate | Merge two or more PDFs into one |
PdfFileEditor.Extract | Extract a page range to a new PDF |
PdfContentEditor | Modify page content (text, annotations, actions) |
PdfFileSignature | Sign and verify PDF digital signatures |
PdfFileStamp | Overlay text or image stamps on pages |
PdfConverter | Render PDF pages to raster images |
FormattedText | Styled text descriptor for stamp operations |
FontStyle | Enumeration of font styles (bold, italic, etc.) |
EncodingType | Character encoding enumeration |