I use the RedactionAnnotation
class to process PDF documents, but it throw IndexOutOfRangeException.
Version info:
Aspose.PDF for Net 23.6
The demo code
void Main()
{
var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Downloads\test.pdf");
foreach (var page in doc.Pages)
{
var annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 595, 720));
annot.FillColor = Aspose.Pdf.Color.White;
annot.Color = Aspose.Pdf.Color.White;
page.Annotations.Add(annot);
annot.Redact();
}
doc.Save(@"C:\Users\54390\Desktop\output.pdf");
}
The demo file
test.pdf (521.1 KB)
The screenshot
20230711220705.png (25.0 KB)