Hello, I ran into a problem when replacing text in landscape documents. When we make a replacement in a line that consists of several words, sometimes the part of the line that is to the right of the replacement moves down.
void landscapeReplacement() throws IOException {
var inputStream = new ClassPathResource("pdf/testLandscape.pdf").getInputStream();
var document = new Document(inputStream);
var page = document.getPages().get_Item(1);
var absorber = new TextFragmentAbsorber();
absorber.setTextSearchOptions(new TextSearchOptions(new Rectangle(258, 240, 285, 249), false));
page.accept(absorber);
List<TextFragment> result = StreamSupport.stream(absorber.getTextFragments().spliterator(), true).collect(Collectors.toList());
result.get(0).setText("[**]");
save(document, "TestAssembler.pdf");
}
testLandscape.pdf (606.3 KB)
see result.pdf.result.pdf (668.5 KB)
and result2.png , this is what the page looks like if you make a replacement in each line
result2.png (16.8 KB)
I really think that the problem is in the landscape pages, because I tried on several examples and this situation only occurs in them and only when the replacement is done for a multi-word line.
Is there any workaround for this or what can I do with it?
Thanks!