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

Free Support Forum - aspose.com

Removing text in a particular area [Aspose.pdf]


We need to implement removing text in a particular area on a pdf file page and filling that area with a colored rectangle.

Actually, it is like a protection\redaction function in the Adobe Acrobat Pro.

Is it possible to do this by using aspose.pdf?


Thanks for contacting support.

In order to accomplish this requirement, you may consider replacing the text contents in particular page region and then add SquareAnnotation over similar location. For further details, please visit Extract Text from an particular page region (you can then run text replace code to replace each character with blank character).

In order to add Annotation, please try using following code snippet.



Document document = new Document("c:/pdftest/InputFile.pdf");

//extract actions

Page page = document.Pages[1];

Aspose.Pdf.InteractiveFeatures.Annotations.SquareAnnotation square = new SquareAnnotation(page, new Aspose.Pdf.Rectangle(10, 10, 30, 30));

Border border = new Border(square);

border.Width = 5;

border.Dash = new Dash(1, 1);

square.Border = border;

square.Color = Aspose.Pdf.Color.Red;

//add annotation in the annotations collection of the page



Thanks for quick reply,

But we need to implement the same feature as "protection\text redaction" feature in the Adobe Acrobat Pro.

Is it possible to do this by using Aspose.Pdf?


Thanks for sharing the details.

Aspose.Pdf for .NET does not support the text redaction directly. However you may consider searching the particular text, get its coordinates, replace the text with blank characters and draw a rectangle on same coordinates. You may consider visiting the following link for further details on Replace Text Based on a Regular Expression