RedactAnnotation.Redact() throws Exception

I’m using the redaction to remove parts of a PDF page. Please see TextFragment over filled rectangle not visible, there is an example.

We have now 3 PDFs which throws the following Exception when doing this. As the exception is occuring within Aspose I would be grateful if you could analyse this.

The Exception is:

   bei System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)
   bei #=zxoGZsrR9$MSi6FqY6JSs2rk=.#=zs6B406lJBTKhK30nfN3bojBV7YEM(Bitmap #=zhrLvylc=, Rectangle #=zYdDy1L5d7zNKkBS6xg==, Color #=z4hEFhfQ=)
   bei #=zCFTSlkXIt6p79xo5pCmKDDI4TLKRtOrcWA==.#=zAZlvcWGH7WkoRe7S4w==(Page #=zjIZJRfY=, Rectangle #=z383O7tQ=, Color #=z4hEFhfQ=)
   bei Aspose.Pdf.Annotations.RedactionAnnotation.Redact()
   bei ManipulateInvoiceTest.InvoiceManipulator.AddHeaderBlank(Page page, Int32 zIndex) in D:\src\Kundenprojekt_10149_ASS\src\Utils\AsposeRedactProblem\InvoiceManipulator.cs: Zeile28
   bei ManipulateInvoiceTest.InvoiceManipulator.CreateFooterHeader() in D:\src\Kundenprojekt_10149_ASS\src\Utils\AsposeRedactProblem\InvoiceManipulator.cs: Zeile49
   bei appGenerics.AssWebApp.Program.Main(String[] args) in D:\src\Kundenprojekt_10149_ASS\src\Utils\AsposeRedactProblem\Program.cs: Zeile23

Aspose PDF Version: Aspose.PDF.Drawing 25.5.0

I’ve attached a Visual Studio solution which will cause the Exception.
Thanks!

AsposeRedactProblem.zip (469.0 KB)

@HauptlorenzAG

The RedactionAnnotation.Redact() method is designed to flatten the annotation and remove any text or images beneath the redacted area on a PDF page. However, if you are encountering exceptions when using this method, it could be due to various reasons such as the specific content of the PDFs you are working with or potential issues within the Aspose library version you are using (25.5.0).

To troubleshoot the exception you are facing, consider the following steps:

  1. Check PDF Content: Ensure that the PDFs you are trying to redact do not have any unusual or unsupported content that might cause the method to fail. This includes checking for corrupted files or complex structures.

  2. Update Aspose Library: If possible, try updating to the latest version of the Aspose.PDF library. There may have been bug fixes or improvements in newer versions that could resolve the issue.

  3. Review Exception Details: Look closely at the exception message you are receiving. It may provide clues about what is going wrong. Common issues can include accessing null references or attempting to redact areas that are not valid.

  4. Test with Simplified PDFs: Create a simple PDF with minimal content and test the redaction on that. This can help determine if the issue is specific to the PDFs you are currently using.

  5. Consult Documentation: Review the official Aspose documentation for the RedactionAnnotation.Redact() method to ensure you are using it correctly and to understand any limitations or requirements.

If the problem persists after these steps, consider sharing the specific exception message and details about the PDFs in a support forum or with Aspose support for further assistance. This will help in diagnosing the issue more effectively.

For more detailed information about the RedactionAnnotation.Redact() method, you can refer to the official documentation here.

If you have a Visual Studio solution that reproduces the issue, providing that to the support team can also be very helpful in diagnosing the problem.

Sources:
[1]: RedactionAnnotation.Redact | Aspose.PDF for .NET API Reference

Can please a human have a look? :wink:

@HauptlorenzAG

We are checking it and will get back to you shortly.

1 Like

@HauptlorenzAG

Are you doing this under Windows or Linux?

It’s failing on both.

I’ve reproduced this on my windows 11 machine but the original exception occured in a linux docker container (Ubuntu).

@HauptlorenzAG
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-60097

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thank you very much.