I want to provide PDF redaction functionality by using PdfCleanUpProcessor
and the following code:
Rectangle redactionRectangle = new Rectangle(74, 503, 385, 761);
PdfReader pdfReader = new PdfReader(sourcePath);
PdfStamper pdfStamper = new PdfStamper(pdfReader,
new FileStream(destinationPath, FileMode.Create));
List<PdfCleanUpLocation> cleanUpLocations = new List<PdfCleanUpLocation>
{
new PdfCleanUpLocation(1, redactionRectangle, BaseColor.WHITE)
};
PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(cleanUpLocations, pdfStamper);
cleaner.CleanUp();
pdfStamper.Close();
This works fine on PDFs with no images, but PDFs with images cause exceptions.
Running on the linked file throws:
The color depth 1 is not supported.
And running on the linked file throws:
Object reference not set to an instance of an object.