PDF Facades
Facade Pattern
All facade classes in org.aspose.pdf.facades follow the same lifecycle:
bindPdf() → operations → save(). They accept file paths, streams, or
Document objects.
PdfAnnotationEditor
Flatten, delete, or count annotations across the entire document:
try (PdfAnnotationEditor editor = new PdfAnnotationEditor()) {
editor.bindPdf("input.pdf");
editor.flattenAnnotations();
editor.save("output.pdf");
}deleteAnnotations(annotationType) removes a specific annotation type by name.
PdfBookmarkEditor
Create and delete PDF outline entries (bookmarks):
try (PdfBookmarkEditor editor = new PdfBookmarkEditor()) {
editor.bindPdf("input.pdf");
editor.deleteBookmarks();
editor.save("output.pdf");
}PdfContentEditor
Replace text in PDF content streams across the whole document or on a specific page:
try (PdfContentEditor editor = new PdfContentEditor()) {
editor.bindPdf("template.pdf");
editor.replaceText("{{Name}}", "John Smith");
editor.save("output.pdf");
}PdfFileSecurity
Encrypt a document with AES-256 and set access permissions via DocumentPrivilege:
try (PdfFileSecurity security = new PdfFileSecurity("input.pdf", "out.pdf")) {
DocumentPrivilege priv = DocumentPrivilege.getForbidAll();
priv.setAllowPrint(true);
security.encryptFile("user", "owner", priv, KeySize.x256);
}PdfExtractor
Extract text page by page from a PDF document:
try (PdfExtractor extractor = new PdfExtractor()) {
extractor.bindPdf("document.pdf");
extractor.extractText();
while (extractor.hasNextPageText()) {
String text = extractor.getNextPageText();
}
}PdfFileStamp
Add page numbers or watermark stamps to PDF pages:
try (PdfFileStamp stamp = new PdfFileStamp("in.pdf", "out.pdf")) {
stamp.addPageNumber("Page #", PageNumberingStyle.NumeralsArabic, 0, 0, 0, 20);
}