Long string replace does not format correctly

My goal is to relace the “Transaction” with “Black Rock Assest Management” . The output format goes funky. Here is my code:



public static void main(String[] args) {

Document pdfDocument = new Document(“C:/Users/jing.luo/CoverLetterTemplateA.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Transaction”);
textFragmentAbsorber.getTextReplaceOptions().setReplaceAdjustmentAction(TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation);
pdfDocument.getPages().accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection =textFragmentAbsorber.getTextFragments();
for (TextFragment textFragment : (Iterable) textFragmentCollection) {
textFragment.setText(“Black Rock Assest Management”);
}
pdfDocument.save(“C:/Users/jing.luo/CoverLetterTemplateA_long_replacement.pdf”);

}


Hello, i’m having an issue with the opposite, longer string being replaced by a shorter string. The formatting will be off. Any clues with this? I’m using PdfContentEditor witih .net

jing.luo:
My goal is to relace the “Transaction” with “Black Rock Assest Management” . The output format goes funky. Here is my code:


public static void main(String[] args) {

Document pdfDocument = new Document(“C:/Users/jing.luo/CoverLetterTemplateA.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“Transaction”);
textFragmentAbsorber.getTextReplaceOptions().setReplaceAdjustmentAction(TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation);
pdfDocument.getPages().accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection =textFragmentAbsorber.getTextFragments();
for (TextFragment textFragment : (Iterable) textFragmentCollection) {
textFragment.setText(“Black Rock Assest Management”);
}
pdfDocument.save(“C:/Users/jing.luo/CoverLetterTemplateA_long_replacement.pdf”);

}


Hi Jing,

Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

jcunanan:
Hello, i’m having an issue with the opposite, longer string being replaced by a shorter string. The formatting will be off. Any clues with this? I’m using PdfContentEditor witih .net
Hi Jonathan,

Thanks for contacting support.

Can you please share the input PDF file and code snippet, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Thanks for looking into this. Do you have any updates? Could you provide any ETA? Our project has a hard deadline and is depending on this.

jing.luo:
Thanks for looking into this. Do you have any updates? Could you provide any ETA? Our project has a hard deadline and is depending on this.
Hi Jonathan,

As we recently have noticed earlier reported issue, so its pending for review and is not yet resolved. However the product team will surely consider investigating/fixing it as per development schedule and as soon as we have some definite updates regarding its resolution, we will let you know. Please be patient and spare us little time. We are sorry for this delay and inconvenience.

The issues you have found earlier (filed as PDFJAVA-36828) have been fixed in Aspose.PDF for Java 19.11.