The redaction annotations work well for me in general, but there are issues when annotating bitonal images (typically PDFs generated from a scanner). It appears that when a redaction is applied onto a bitonal image, the resulting image is always re-encoded in colour (even when the annotation itself is simply black or white), which has the following serious issues:
-
Increases file size - typically the redacted files are somewhere between 4 and 10 times the size of the original.
-
Takes a long time - the re-encoding takes significant CPU time, often 5-10 seconds
-
Reduces quality - the original bitonal image is compressed in a non-lossy way, but the redacted version suffers from JPEG compression artefacts.
Reproduction code is as follows:
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Pdf.lic");
Document pdf = new Document("bitonal.pdf");
RedactionAnnotation ra = new RedactionAnnotation(pdf.Pages[1], new Aspose.Pdf.Rectangle(100, 500, 200, 600));
ra.FillColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black);
pdf.Pages[1].Annotations.Add(ra);
ra.Redact();
pdf.Save("redacted.pdf");
(Note that it is important to use a licensed version to reproduce, because in eval mode the redactions are not fully applied, and the issue does not occur)
I’ve attached sample input and output files. Note that the input file is 58kb and the output 241kb, and if you zoom in close on the output file you’ll see the compression artefacts.
Many thanks for any help you can provide.
George
bitonal.pdf (57.7 KB)
redacted.pdf (240.3 KB)