I am using the TextFragmentAbsorber, TextFragmentCollection and TextFragment Free version to remove the Chinese text in my PDF file. However it only works on the first 5 pages of the 22-pages PDF. I tried splitting the PDF pages file into 22 PDF files, and use the Aspose function on all the 22 of the 1-page PDF files, and it works. May I know why it wont work when there are more than 5 pages?
This is my code :
Document pdfDoc = new Document(“C:\Downloads\sample.pdf”);
String chineseWords = “[\u4e00-\u9fa5]”;
Pattern pattern = Pattern.compile(chineseWords);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(pattern);
pdfDoc.getPages().accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();
for (TextFragment textFragment : (Iterable) textFragmentCollection) {
textFragment.setText(“”);
}
pdfDoc.save(“C:\Downloads\sample_after_using_aspose.pdf”);
pdfDoc.close();
These are my PDF files :
sample.pdf (1.0 MB)
sample_after_using_aspose.pdf (1.1 MB)
@chetsadasia
What version of the library are you using?
The latest one, aspose-pdf-24.7
Updated my code on the TextFragmentAbsorber constructor. Posted the wrong one just now.
@chetsadasia
In the library for the trial version (without using a license) there were strict restrictions on the number of elements - no more than four. Including the number of pages and the number of elements found.
In the latest versions, the restrictions have been relaxed.
I will study this issue and write to you on Monday.
@chetsadasia
Thank you for writing, this case is very important for us.
I checked the library with the license connected and the result is valid. I am attaching the resulting document.
sample-outLic.pdf (1022.3 KB)
However, without a license, the replacement is really performed only for four (five) pages.
This must look like a library error?
Once again, thank you for looking into it and writing to us.
I will create a task for the development team about this.
@chetsadasia
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-57904
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.
@chetsadasia
I checked with the development team.
In the latest versions of the library, the restrictions for the trial version (without a license) have been relaxed.
In fact, only the corresponding inscription and the restriction on working with four pages remained, which is what you were experiencing. Unfortunately, the documentation is a bit behind and I cannot refer to it now.
To evaluate the full capabilities of the library, you can purchase a temporary license for a month.
You can request a temporary license here: Temporary License - Purchase - aspose.com
@chetsadasia
The mentioned restriction are specified in: