I was wondering if there was a big difference between the functionality of Facades.PdfAnnotationEditor.RedactArea() and RedactionAnnotation.Redact() behind the scenes? I’ve looked at some files redacted by both and haven’t noticed a huge difference from the final product, but the facade implementation seems to be quicker and uses significantly less memory. Is there a big difference beneath the scenes as to how these methods effect a document?
var filePath = "ManyPdfObjects.pdf";
using (var document = new Document(filePath))
{
var editor = new PdfAnnotationEditor(document);
var page = document.Pages[1];
editor.RedactArea(page.Number, new Rectangle(0, 0, page.CropBox.Width, page.CropBox.Height), System.Drawing.Color.Black);
var annotations = page.Annotations;
document.Save("RedactedWithFacades.pdf");
}
Annotation Redaction:
var filePath = "ManyPdfObjects.pdf";
using (var document = new Document(filePath))
{
var page = document.Pages[1];
var annotation =
new RedactionAnnotation(page, new Rectangle(0, 0, page.CropBox.Width, page.CropBox.Height));
annotation.Redact();
var annotations = page.Annotations;
document.Save("RedactedWithRedactionAnnotation.pdf");
}
Sample files included below with results from redacting with facades and redacting with annotations. ManyPdfObjects.zip (3.2 MB)
I like to inform that RedactArea just redacts area in the document (i.e remove contents and filling area with required color), RedactAnnotation is specific type of annotation which allows to do the same thing. This annotation allows previously create annotation and redact it later. RedactArea functioning without annotation creation.