Part of nearby token removed after using RedactionAnnotation on punctuation marks. Example:
image.png (45.9 KB)
Java version: 11
Aspose PDF version: 21.10
Code snippet
@Test
void testReduction() {
var document = new Document("testFile.pdf");
var page = document.getPages().get_Item(1);
var textFragment = findTextFragment(page, ":");
var annotation = new RedactionAnnotation(page, textFragment.getRectangle());
annotation.setFillColor(Color.getBlueViolet());
annotation.setColor(Color.getBlack());
annotation.redact();
page.getAnnotations().add(annotation);
document.save("result.pdf");
}
private TextFragment findTextFragment(Page page, String searchValue) {
var absorber = new TextFragmentAbsorber(searchValue);
page.accept(absorber);
return absorber.getTextFragments().get_Item(1);
}
Original file: testFile.pdf (402.5 KB)
Do you have some workaround for it?