Replace text is not working with aspose.pdf java

Hi,

I was trying to replace the text using pdfContentEditor and also with TextFragmentAbsorber in the existing pdf file.

After replacing the text, i could see only few chars displayed(i.e. many characters are missing) in the updated pdf file.

Please let me know if anything missing during the replace text.

below is the code snippet am using for this.
com.aspose.pdf.facades.PdfContentEditor pdfContentEditor = new com.aspose.pdf.facades.PdfContentEditor();
pdfContentEditor.bindPdf(doc);
pdfContentEditor.replaceText("#UPPER LETTERS1#",1, “ABCDEFGHIJKLMNOPQRSTUVWXYZ”);
pdfContentEditor.replaceText("#lower letters2#",1, “abcdefghijklmnopqrstuvwxyz”);
pdfContentEditor.save(outFile);

Note: When I copy the text from pdf, and paste in any editor, am able to see all characters.

Thanks,
Shivaji

Hi Shivaji,


Thanks for using our API’s.

Can you please share the resource PDF file, so that we can test the scenario in our environment. We are sorry for this inconvenienc.e

Hi Nayyer,

Thank you for looking into this issue.

As requested, i have attached the pdf files here.
PDF_xxx is original file, where I am searching for text,
FinalPDF_xxx is the resultant PDF file after replace.

I am attaching the code snippet below which i used for replacing the text.
//open input PDF
com.aspose.pdf.facades.PdfContentEditor pdfContentEditor = new com.aspose.pdf.facades.PdfContentEditor();
pdfContentEditor.bindPdf(doc);
TextReplaceOptions opt = new TextReplaceOptions(TextReplaceOptions.ReplaceAdjustment.AdjustSpaceWidth);
pdfContentEditor.setTextReplaceOptions(opt);
//replace text on all pages
pdfContentEditor.replaceText("#Title#",1, “Don”);
pdfContentEditor.replaceText("#Prefix#",1, “Mr.”);
pdfContentEditor.replaceText("#Name#",1, “ABCDEFGHIJKLMNOPQRSTUVWXYZ”);
pdfContentEditor.replaceText("#Designation#",1, " ثمخي هتشرهاس");
pdfContentEditor.replaceText("#Entity Name#",1, “abcdefghijklmnopqrstuvwxyz”);
//save output PDF
pdfContentEditor.save(outFile);


Thanks.
Shivaji

Hi Shivaji,

Thanks for sharing your sourced document and code. I have tested your scenario with Aspose.Pdf for Java 10.4.1 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWJAVA-35030 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

Please feel free to contact us for any further assistance.

Best Regards

Hi,

Can we have some timelines for resolution of this issue, based on that we will notify the customer.

Thanks,
Shivaji

Hi Shivaji,


Thanks for your inquiry. I am afraid we noticed your reported issue recently and yet it is pending for investigation in the queue with other issues, already under investigation/resolution. We can not share an ETA, we will be in a good position to share an ETA as soon as our team completes its analysis. We will notify you as soon as we made some significant progress towards issue resolution.

We are sorry for the inconvenience caused.

Best Regards,

Thank you!

@shivaji_dole

Thanks for your patience.

We are pleased to inform you that earlier reported issue PDFJAVA-35030, has been resolved in latest version Aspose.Pdf for Java 17.12.

Please try using the latest release version and in case you face any issue, please feel free to contact us.