Java version: 11
Aspose PDF version: 21.8
Code sample:
Document doc = new Document("test.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
textFragmentAbsorber.setPhrase("34");
textFragmentAbsorber.setTextReplaceOptions(new TextReplaceOptions(WholeWordsHyphenation, Scope.REPLACE_FIRST));
textFragmentAbsorber.visit(doc.getPages().get_Item(1));
TextFragmentCollection textFragments = textFragmentAbsorber.getTextFragments();
textFragments.get_Item(1).setText("444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444 444");
doc.save("D:/test_output.pdf");
test.pdf (59.9 KB)
test_output.pdf (59.0 KB)