Java version: 11
Aspose PDF version: 21.8
Code sample:
PdfContentEditor editor = new PdfContentEditor();
editor.bindPdf("test_invisible_words.pdf");
editor.getTextReplaceOptions().setReplaceAdjustmentAction(TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation);
editor.replaceText("34", 1, "444");
editor.save("test_invisible_words_result.pdf");
Result: “drug.” is invisible.
The same happens when I use TextFragmentAbsorber
Document doc = new Document("test_invisible_words.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");
doc.save("test_invisible_words_output.pdf");
test_invisible_words.pdf (51.2 KB)
test_invisible_words_output.pdf (52.9 KB)
Do you have some workaround for it?
How can I detect this issue programmatically?