Remove all text from page with TextFragmentCollection is to slow

@KDSSHO,

Sure, we will keep you informed regarding the available updates.

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

@KDSSHO

In addition to above notification, we have used following code snippet to remove all text from PDF document and it took less than 2 seconds to complete the operation.

Document doc = new Document(inFile);
System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew();
TextFragmentAbsorber absorber = new TextFragmentAbsorber();
absorber.RemoveAllText(doc);
doc.Save(outFile);
sw.Stop();

Hi Asad,

I downloaded 18.7 and tested above snippet which seems not to be working.
I can’t build these 2 lines.

list.AddRange(operatorSelector.Selected);
page.Contents.Delete(list);

@KDSSHO

You can simply modify your code snippet as follows, in order to get it working correctly.

page.Contents.Delete(operatorSelector.Selected);

Furthermore, please also check the code snippet, which we have shared in earlier response. We have introduced a new method TextFragmentAbsorber.RemoveAllText(), which removes text from PDF document efficiently. You may also use this approach in order to remove all text from your PDF documents.

Hi Asad,

Thank you very much I could fix it just as you mentioned!
I’ll check RemoveAllText(), too.