We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replacemet issue with bullets and overlapping text

Hi.
We have a issue with text replacement. When we do replacement for text fragment that contains bullets - after replacement document have overlapping text.

Code snippet:

    var document = new Document("src/test/resources/pdf/test_5.pdf");
    var page = document.getPages().get_Item(1);
    Map<String, Rectangle> tokens = new LinkedHashMap<>();
    tokens.put("ICH", new Rectangle(222.25, 629.758, 242.902, 642.9580000000001));
    tokens.put("person", new Rectangle(212.402, 660.4780000000001, 244.53799999999998, 673.6780000000001));

    Map<String, String> replacementValues = new HashMap<>();
    replacementValues.put("ICH", "International Conference on Harmonisation");
    replacementValues.put("person", "individual human that providing services in connection with the Clinical Trial to evaluate the efficacy");

    tokens.forEach((searchValue, rectangle) -> {
        var absorber = new TextFragmentAbsorber();
        absorber.setPhrase(searchValue);
        absorber.setTextSearchOptions(new TextSearchOptions(rectangle));
        absorber.setTextReplaceOptions(new TextReplaceOptions(WholeWordsHyphenation, REPLACE_FIRST));
        page.accept(absorber);
        var textFragment = absorber.getTextFragments().get_Item(1);
        textFragment.setText(replacementValues.get(searchValue));
    });

    document.save("src/test/resources/pdf/result.pdf");

Java version: 11
Aspose PDF version: 21.8

Source document:
test_5.pdf (280.6 KB)
Result looks like this:
image.png (26.1 KB)

Could you, pls, describe the reason why?
And do you have some workaround for it?

@dkuksa

We were able to replicate the issue in our environment while using 21.9 version of the API. Hence, have logged it as PDFJAVA-40899 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.