Processing PDF documents with the RedactionAnnotation class throws an exception

I use the RedactionAnnotation class to process PDF documents, but there are several problems in the process of processing, please help me to see why.

Version info:

Aspose.PDF for Net 23.2

Issue 1

The demo code

void Main()
{
	var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Desktop\6下第5单元详细考点梳理.pdf");
	var color = Aspose.Pdf.Color.White;
	foreach (var page in doc.Pages)
	{
		var annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 200, 200));
		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

6下第5单元详细考点梳理.pdf (405.8 KB)

The screenshot

20230304161525.png (28.5 KB)

Issue 2

The demo code

void Main()
{
	var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Desktop\六年级数学期中试卷(学生版).pdf");
	var color = Aspose.Pdf.Color.White;
	foreach (var page in doc.Pages)
	{
		var annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 200, 200));
		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

六年级数学期中试卷(学生版).pdf (1.6 MB)

The screenshot

20230304161733.png (60.3 KB)

Issue 3

The demo code

void Main()
{
	var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Desktop\JGT434-2014 木结构防护木蜡油.pdf");
	var color = Aspose.Pdf.Color.White;
	foreach (var page in doc.Pages)
	{
		var annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 200, 200));
		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

JGT434-2014 木结构防护木蜡油.pdf (2.6 MB)

The screenshot

20230304162013.png (24.7 KB)

@sullivan

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-53792

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.

@asad.ali
Hello,Has any progress on this issue?

@sullivan

We are afraid that the earlier logged ticket could not get resolved yet due to other issues in the queue logged prior to it. Nevertheless, it is under the phase of the investigation and as soon as we make some progress towards its resolution, we will inform you via this forum thread. Please spare us some time.

We are sorry for the inconvenience.

@sullivan

We have made some investigations and divided the original issues into subtasks. The fix to this issue is expected to be included in 23.6 version of the API that will be released in June 2023. Furthermore, Your file is not in the correct data format on page 7.

There is an appeal to fonts in resources. But there are no fonts.

This page is also not displayed in Adobe and it is not clear how to check the correctness of our program.

We can recommend wrapping in try-catch content for each and work with already received exceptions.
Then all correct pages will be processed, and broken ones will fall into the try-catch and where there will be an opportunity to process them in any way.

void Main()
{
    var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Desktop\53792_1.pdf");
    foreach (var page in doc.Pages)
    {
        try
        {
            var annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 200, 200));
            annot.FillColor = Aspose.Pdf.Color.White;
            annot.Color = Aspose.Pdf.Color.White;
            page.Annotations.Add(annot);
            annot.Redact();
        }
        catch
        {
            // process exception
        }
    }
    doc.Save(@"C:\Users\54390\Desktop\53792_1.pdf");
}

The issues you have found earlier (filed as PDFNET-53792) have been fixed in Aspose.PDF for .NET 23.6.

@aspose.notifier
@asad.ali

Thank you for your reply.
The Issue 1 is still not resolved, If I catch the exception, some pages may not be processed. Can you handle the issue of font resources? I tried to use the Repair method, but still can’t solve it.

Also, I found a other bug.

void Main()
{
	var doc = new Aspose.Pdf.Document(@"C:\Users\54390\Downloads\default (3).pdf");
	var color = Aspose.Pdf.Color.White;
	foreach (var page in doc.Pages)
	{
		var annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(0, 0, 400, 400));
		annot.FillColor = Aspose.Pdf.Color.White;
		annot.Color = Aspose.Pdf.Color.White;
		page.Annotations.Add(annot);
		annot.Redact();
	}
	doc.Save(@"C:\Users\54390\Downloads\output.pdf");
}

The demo file

六年级数学期中试卷(学生版).pdf (1.6 MB)

The screenshot

image.png (20.3 KB)

@sullivan

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-54942

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.

@sullivan

The Issue 1 is still not resolved, If I catch the exception, some pages may not be processed. Can you handle the issue of font resources? I tried to use the Repair method, but still can’t solve it.

The file that exists in issue 1 is broken on page 7. Adobe Acrobat Reader can’t even open this page.
We can’t solve this problem either. We are currently working on improving the Repair method.
Whether this will fix the error with the fonts, we can’t say right now.

Regarding the new issue that you found, we are working on resolving it too.

@asad.ali

I tried to use ilovepdf to repair this document, and the document can be processed normally after processing, I hope you can refer to their repair function, thank you!

@sullivan

Thanks for sharing the information. We have updated the ticket information and will definitely investigate from this perspective.