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

Free Support Forum - aspose.com

Clearing Areas on PDF (RedactArea) Causing Black Boxes in Place of Images

I am trying to clear areas on a .pdf document using Aspose.Pdf (using version 19.4; also tried with v17.4) and its “RedactArea” method.

It is clearing the area that is specified correctly, but only when underneath that area there is only text. If there happens to be an image in that area, full or partial, that area will be cleared (say, on the 1st page) but there will be black boxes over images that appear in that area on other pages.

I’ve included the .pdf that I’m clearing the areas on (“RevSpringTestPdf.pdf”) and that .pdf after it has been cleared (“RevSpringTestPdfBlackBoxes.pdf”).

RevSpringTestPdf.pdf (267.7 KB)
RevSpringTestPdfBlackBoxes.pdf (183.7 KB)

Do you know what is causing this behavior, and if it can be resolved? Thank you very much for any assistance.

Here is the code that I am using to clear areas:

public class Coordinate
            public double X;
            public double Y;

            public Coordinate()
                this.X = 0;
                this.Y = 0;

            public Coordinate(double x, double y)
                this.X = x;
                this.Y = y;

        static void Main()
            FileInfo pdfFile = new FileInfo(@"c:\temp\RevSpringTestPdf.pdf");

            RemoveContent(pdfFile, new List<int>() { 2 }, new Coordinate(1.0, 4.0), new Coordinate(6.5, 7.0));
            RemoveContent(pdfFile, new List<int>() { 1 }, new Coordinate(0.25, 0.25), new Coordinate(7.5, 2.0));

        public static void RemoveContent(FileInfo pdfFileInfo, List<int> pageNumbers, Coordinate bottomLeftInInches, Coordinate topRightInInches)
            Document pdfDocument = new Document(pdfFileInfo.FullName);
            PdfAnnotationEditor annotator = new PdfAnnotationEditor(pdfDocument);
            foreach (int pageNumber in pageNumbers)
                Page page = pdfDocument.Pages[pageNumber];
                Rectangle rectangle = new Rectangle(bottomLeftInInches.X * 72, page.MediaBox.Height - bottomLeftInInches.Y * 72,
                    topRightInInches.X * 72, page.MediaBox.Height - topRightInInches.Y * 72);

                annotator.RedactArea(pageNumber, rectangle, page.Background.ToRgb());

            string tempPath = pdfFileInfo.FullNameWithDifferentExtension(".temppdffile");

            annotator = null;
            pdfDocument = null;

            File.Move(tempPath, pdfFileInfo.FullName);


Thank you for contacting support.

We are checking it and will get back to you with our findings soon.


Thanks very much! We are using the area clearing via the RedactArea() method in a new process for clients, so I am definitely looking forward to finding something out.


Thank you for being patient.

We have been able to reproduce the issue in our environment. A ticket with ID PDFNET-46761 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, you may try to Redact certain page region with RedactionAnnotation and feel free to contact us if you need any further assistance.

We are sorry for the inconvenience.