Issues with redaction of bitonal images

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:

  1. Increases file size - typically the redacted files are somewhere between 4 and 10 times the size of the original.

  2. Takes a long time - the re-encoding takes significant CPU time, often 5-10 seconds

  3. 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)

@GeorgeH

Thanks for contacting support.

We were able to notice the issue(s) which you have mentioned with Aspose.PDF for .NET 18.12 and logged them under the ticket ID PDFNET-45836 in our issue tracking system. We will further investigate the logged ticket in details and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

5 years on, I think this issue still exists? Are there any new options or techniques that would enable me to redact a bitonal PDF without the speed/size/quality issues mentioned in the original post?

Many thanks,

George

@GeorgeH

We are afraid that we could not come up with any alternative or workaround related to the original issue posted here. The priority of the ticket has been lifted to the next level and we have recorded your concerns as well. As soon as we have some information about the fix ETA, we will inform you. We apologize for the delay and the inconvenience caused.