Hi,
I am trying to use Aspose.PDF for Java to find and replace the text.
Following is my code snippet.
Document pdfDocument = new Document(inputStream);
TextFragmentCollection textFragmentCollection = getTextFragmentCollection(pdfDocument);
for (TextFragment textFragment : textFragmentCollection) {
textFragment.getTextState().setFont(FONT);
textFragment.setText(clearText);
}
pdfDocument.save(outputStream);
But after replacement, the replaced text seem to have white trailing space. I am running this on Ubuntu 12.04
Original
Screen Shot 2017-08-06 at 8.29.07 AM.png (7.9 KB)
Modified
Screen Shot 2017-08-06 at 8.29.13 AM.png (3.5 KB)
I am attaching the following
- Original PDF
- Java Code
- Font used
- Output PDF
aspose_test.zip (221.7 KB)
Please let me know what could be wrong here.