Redaction issue using Aspose.PDF

Hi,

I’m trying to redact annotation on a PDF file (generated from JPG file) using Aspose.PDF library (ver 21.11.0.0) using code similar to what’s provided on Aspose site Extra Annotations using C#|Aspose.PDF for .NET.

Code sample…

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

// Open document
Document doc = new Document(dataDir + "input.pdf");

// Create RedactionAnnotation instance for specific page region
RedactionAnnotation annot = new RedactionAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 500, 300, 600));
annot.FillColor = Aspose.Pdf.Color.Black;
annot.BorderColor = Aspose.Pdf.Color.Yellow;
annot.Color = Aspose.Pdf.Color.White;
// Text to be printed on redact annotation
annot.OverlayText = "Confidential";
annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;
// Repat Overlay text over redact Annotation
annot.Repeat = false;
// Add annotation to annotations collection of first page
doc.Pages[1].Annotations.Add(annot);
// Flattens annotation and redacts page contents (i.e. removes text and image
// Under redacted annotation)
annot.Redact();
dataDir = dataDir + "RedactPage_out.pdf";
doc.Save(dataDir);

When we use Adobe Pro to open saved PDF file and try to edit, we can select and move redaction and that exposes original image that should have been removed by redaction. I came across old article in this support forum Redaction of Vector Images in PDFs - #2 by asad.ali . I don’t know if issue i’m describing is exactly same as this article or not. Can you let me know why its not sticking redaction?

@hirenp

Could you please ZIP and attach your input, problematic output and expected output PDF files here for testing? We will investigate the issue and provide you more information on it.

Tahir,

Attached is a zip file which contains the original source file (000001_new.pdf, JPG converted to PDF), redacted image (test_RedactPage_out.pdf), screenshots of how redaction got removed from Adobe Pro (2021-12-04 12_13_21_Resize3.png is screenshot of final pdf after redaction was deleted from Adobe Pro). I’ve included steps to show how we were able to remove redaction.

Steps to Remove are:

  1. Open Image in Adobe pro (you’ll notice as you open the PDF, the document will flash uncovering the image behind the redaction.

  2. Right click inside the image and click “Edit Image/Text”. you’ll also notice the image flashing uncovering what’s underneath the redaction.

  3. Select the redaction.

  4. On the middle left of the image, try to resize. Make sure you’re selecting the redaction and not the whole image

  5. slowly drag / resize the redaction and you should be able to see the image underneath. At this point you can click the delete key to delete the whole redaction . If when resizing you dont see the image underneath you might have selected the whole image instead and you’ll need to try again.

The actual code used to redact PDF.

        // Open document
        Document doc = new Document(@"D:\svn\PDFTest\test.pdf");
        
        // Create RedactionAnnotation instance for specific page region
        RedactionAnnotation annot = new RedactionAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(5, 5, 2000, 1200));
        annot.FillColor = Aspose.Pdf.Color.Black;
        annot.BorderColor = Aspose.Pdf.Color.Yellow;
        annot.Color = Aspose.Pdf.Color.White;
        // Text to be printed on redact annotation
        annot.OverlayText = "Confidential";
        annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;
        // Repat Overlay text over redact Annotation
        annot.Repeat = false;
        // Add annotation to annotations collection of first page
        doc.Pages[1].Annotations.Add(annot);
        // Flattens annotation and redacts page contents (i.e. removes text and image
        // Under redacted annotation)
        annot.Redact();
        var dataDir = @"D:\svn\PDFTest\test_redacted.pdf";
        doc.Save(dataDir);

Let me know if you have any other questions.
Thanks,
Hiren PatelDownloads.zip (5.3 MB)

@hirenp

We are working over your query and will get back to you soon.

@hirenp

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51016. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.