Replace text performance error in pdf

I have match an error , when I delete the text , it did not delete the specify the page region for TextSearch Options.

The code and pdf file is below
image.png (98.8 KB)

这种事实对本人来说意义重大.pdf (447.8 KB)

	public static async Task replaceStringTest(string folderPath, string filename)
	{
		// load PDF file
		Document pdf = new Document(System.IO.Path.Combine(folderPath, filename));

		// instantiate TextFragment Absorber object
		Aspose.Pdf.Text.TextFragmentAbsorber TextFragmentAbsorberAddress = new Aspose.Pdf.Text.TextFragmentAbsorber();

		// search text within page bound
		TextFragmentAbsorberAddress.TextSearchOptions.LimitToPageBounds = false;

		// specify the page region for TextSearch Options
		TextFragmentAbsorberAddress.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(0, 0, 500, 500);

		// search text from first page of PDF file
		pdf.Pages[1].Accept(TextFragmentAbsorberAddress);

		// iterate through individual TextFragment
		foreach (Aspose.Pdf.Text.TextFragment tf in TextFragmentAbsorberAddress.TextFragments)
		{
			// update text to blank characters
			tf.Text = String.Empty.PadLeft(tf.Text.Length, ' ');
		}

		// save updated PDF file after text replace
		pdf.Save(System.IO.Path.Combine(folderPath, "TextUpdated.pdf"));
	}

@yangronglong
Let me clarify if I understood your problem correctly.
If I use the code to remove text in a given rectangle, some characters remain as shown in the attached picture.
Did I understand correctly?

// load PDF file
var pdf = new Document(System.IO.Path.Combine(dataDir, "123.pdf"));

// instantiate TextFragment Absorber object
var TextFragmentAbsorberAddress = new Aspose.Pdf.Text.TextFragmentAbsorber();

// search text within page bound
TextFragmentAbsorberAddress.TextSearchOptions.LimitToPageBounds = false;

// specify the page region for TextSearch Options
TextFragmentAbsorberAddress.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(0, 0, 500, 500);

// search text from first page of PDF file
pdf.Pages[1].Accept(TextFragmentAbsorberAddress);

// iterate through individual TextFragment
foreach (Aspose.Pdf.Text.TextFragment tf in TextFragmentAbsorberAddress.TextFragments)
{
    // update text to blank characters
    //string txt = tf.Text;
    //string newTxt = string.Empty.PadLeft(txt.Length, ' ');
    //tf.Text = string.Empty.PadLeft(tf.Text.Length, ' ');

    tf.Text = string.Empty;
}

// save updated PDF file after text replace
pdf.Save(System.IO.Path.Combine(dataDir, "123-out.pdf"));

123-result.png (28.4 KB)

Yes, you got it.My understanding is that deleting the text within the selected range may change the left and right positions, but it should not affect line wrapping.

@yangronglong
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-56775

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.