We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Blacken/ Annonymiing Text in pdf document Redact Method throws Out of Range Exception

Dear support team,
if I anonymizing this document for example with the Aspose.Pdf.Rectangle(55,56,540,802) the Redact-Method throws an out of range Exception.
Anonymizing Text throws out of Range Exception.pdf (11.5 KB)

Sample Code:
var asposeRect = new Aspose.Pdf.Rectangle(55,56,540,802);
// page is the document I attached
var redactAnnot = new RedactionAnnotation(page, asposeRect)
FillColor = Aspose.Pdf.Color.Black,
Color = Aspose.Pdf.Color.Black,

                    Repeat = true



Can you tell me why?


Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFNET-45062 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

However, until this issue is investigated, you may use Flatten method instead of Redact method as in the line of code below; and then share your kind feedback with us.


We are sorry for the inconvenience.

If I use the Flatten()-Mehtod, I can read the text under the blacken section after I copy and paste the words and phrases to an editor by choice.

But I need to anonymize the words and phrases under the blacken section so that noone can read or copy and paste them.


In that scenario, we are afraid that you would need to wait until the problem with Redact method is rectified.

We are sorry for the inconvenience.


We have investigated the earlier logged ticket. For annotations redacting use PdfAnnotationEditor instead.

For current task use folowing code:

string pdf_source = @"pdf_source.pdf";
string output = @"pdf_output.pdf";
PdfAnnotationEditor annotationEditor = new PdfAnnotationEditor();
annotationEditor.RedactArea(1, new Aspose.Pdf.Rectangle(55, 56, 540, 802), Color.Black);