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 images

Tips and Best Practices

  • Always call Close() or use using to release resources held by facade objects.
  • Use BindPdf with a file path for large files to avoid loading everything into memory at once.
  • Prefer TryConcatenate and TryAppend over their non-Try counterparts for graceful error handling.
  • Facades delegate to the core Document model internally — switch to the core API when you need fine-grained control.
  • The FormEditor facade allows adding new form fields to an existing PDF, not just filling existing ones.

Common Issues

IssueCauseFix
Save() produces empty fileBindPdf was not called before saveAlways bind a source PDF before calling Save
Form field value not writtenField name does not match the PDF’s internal field nameUse Form.FieldNames to list available field names
Concatenation fails silentlyInput file is encrypted or corruptedUse TryConcatenate and check the return value
Signatures invalid after editContent was modified after signingSign 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 / MethodDescription
FormAcroForm facade for reading and writing field values
Form.FillFieldSet a form field value by name
Form.GetFieldRead a form field value by name
FormEditorAdd or modify form fields in an existing PDF
PdfFileEditorMerge, split, extract, and delete PDF page ranges
PdfFileEditor.ConcatenateMerge two or more PDFs into one
PdfFileEditor.ExtractExtract a page range to a new PDF
PdfContentEditorModify page content (text, annotations, actions)
PdfFileSignatureSign and verify PDF digital signatures
PdfFileStampOverlay text or image stamps on pages
PdfConverterRender PDF pages to raster images
FormattedTextStyled text descriptor for stamp operations
FontStyleEnumeration of font styles (bold, italic, etc.)
EncodingTypeCharacter encoding enumeration

See Also

 English