Throw ArgumentOutOfRangeException when Replace Text

Description

When I replace text, it throws ArgumentOutOfRangeException:

 System.String.Substring(Int32 startIndex, Int32 length)
   #=zVCpWUBUoqHMQ2zfntTiDaYYqs4vhj8TyF3LvSjbVcJIv.#=zzmPxqADrOJbQHjbiZw==(String #=zMO7LiuA=, Int32 #=zrEVsUwoYmnd5, Int32 #=zhOCHzUxUqa4X, #=z3wFLupb$3Uvr #=zw7Sf$9222PT1)

Env

  • Windows 11
  • Aspose.PDF for .NET 24.5.1

Code

void Test()
{
	var doc = new Aspose.Pdf.Document(@"C:\Users\Administrator\Desktop\test\test.pdf");
	var textFragmentAbsorber = new TextFragmentAbsorber("专业课复习资料,后续更新");
	doc.Pages.Accept(textFragmentAbsorber);
	var textFragmentCollection = textFragmentAbsorber.TextFragments;
	foreach (var textFragment in textFragmentCollection)
	{
		textFragment.Text = "123456789";// Error!
	}
	doc.Save(@"C:\Users\Administrator\Desktop\test\out.pdf");
}

Test Files

test.zip (333.4 KB)

@xxtears
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-57314

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.

@xxtears
The development team has worked on the task and ArgumentOutOfRangeException does not occur in the upcoming version 25.06. But when opening a document saved after replacement in Acrobat, an error is displayed and the text is not replaced. Manual text replacement in Acrobat Pro also does not work - the original document has violations. In this regard, the task PDFNET-60075 was created to study the possibility of document recovery.

@xxtears
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-60075

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.

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