Hello,
Hi Patrick,
I followed the link but that does not solve the issue. I have attached two PDF files that demonstrate the problem. The first is the one I use when searching for the placeholder text, and the other is the result of the text being replaced and saved to a new PDF file.
Hi Patrick,
Glad you could reproduce it. I know it’s difficult to say, but could you please to try to provide me with an estimate as to when this will be actively worked on? Trying to gauge whether or not I can hold off until it’s fixed or if I need to purchase from another vendor.
Hi Patrick,
Hello, I’m getting pressure from stakeholders regarding this issue. We have to finalize our product choice before the end of September. Is there any updates or timing info you can give to me that I may be able to relay back to my team? I really don’t want to have to go with another vendor, because we have very satisfied with Aspose other than this one issue.
Hi Patrick,
Hi Nayyer Shahbaz,
Hi William,
Hi Tilal Ahmad,
If you need any more information please feel free to contact me further.
Kind Regards,
Hi William,
Thanks for sharing your sample code and document. Please use WholeWordsHyphenation TextReplacementOptions, it tries to distribute words in paragraph after replacement. It will help you to accomplish your requirement.
Dim textFragmentAbsorber As New TextFragmentAbsorber(“«_Email»”)
textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation
Best Regards,
Hi Tilal Ahmad,
Is there a reason for this?
Hi William,
I am also facing same kind of problem.
i am trying to absorb text “first” in pdf file.
sample1.pdf:-contains
My first pdf page My first pdf page My first pdf page My first pdf page
I am using aspose-pdf-12.0.0.jar
trying to replace with “abcdefg1,abcdefg2,abcdefg3,abcdefg4” with the following code.
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("first");
pdfDocument.getPages().accept(textFragmentAbsorber);
for (TextFragment textFragment : (Iterable<TextFragment>) textFragmentAbsorber.getTextFragments()) {
textFragment.setText("abcdefg1,abcdefg2,abcdefg3,abcdefg4");
}
pdfDocument.save(dataDir+"TestFragment.pdf");
But the result ends in same line with incomplete sentences.
Thanks for contacting support.
We could not find any attachment with your post. However, would you please use following code snippet with latest version of the API and in case you still face any issue, please share your sample PDF document with us so that we can test the scenario in our environment and address it accordingly.
Document pdfDocument = new Document(myDir+"Lorem_lpsum.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("book");
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();
TextReplaceOptions textReplaceOptions = new TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation,
TextReplaceOptions.Scope.REPLACE_FIRST);
textFragmentAbsorber.setTextReplaceOptions(textReplaceOptions);
pdfDocument.getPages().accept(textFragmentAbsorber);
for (TextFragment textFragment : textFragmentCollection) {
textFragment.setText("big big big replacement text");
}
FileOutputStream pdfOutpustStream = new FileOutputStream(myDir+"modified.pdf");
pdfDocument.save(pdfOutpustStream);
Thank you very much for the reply.I tried with the above code. It works fine but partially works fine.
I have tried with my own replacing text. PFA. Kindly advice.testreplace.zip (221.2 KB)
Can you please provide more examples on TextReplaceOptions.
Thanks for getting back to us.
We have tested the scenario in our environment with Aspose.PDF for Java 18.11 and were able to notice that text was getting overlapped while replacing it with long string. Hence, we have generated an issue as PDFJAVA-38238 in our issue tracking system for the sake of investigation. We will further investigate the reasons behind this issue and keep you posted with the status of rectification. Please spare us little time.
We are sorry for the inconvenience.