Hi,
I wrote a class that has been wrapping aspose.pdf features to our application. I am trying to replace pdf text to some other text. But it is not replacing the text completely. Capital letters and numbers are not replacing. I tried a lot of various method to resolve this issue.
But it is not working. I have Aspose.Total licence. Can you help me to resolve ?
My sample method to replace text in wrapper class:
public void ReplaceText(string targetText, string sourceText)
{
Document document = new Document(“some_doc.pdf”);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(targetText);
document.getPages().accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();
TextFragment textFragment = textFragmentCollection.get_Item(1);
textFragment.setText(sourceText);
document.save(“new_doc.pdf”);
}
I am also attaching the source pdf file.
In the pdf file i want to replace text “name123” to “NAME123”.
Hi Sumilon,
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWJAVA-35204 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.
Hi,
Hi,
Hi Roel,
Hi Roel,
Hi Roel,
Thanks for the intimation.
I have logged the above stated problem as an investigation ticket in our issue tracking system as PDFCLOUD-38. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
Thank you for being patient.
We have investigated the ticket reported by you PDFJAVA-35204 and would like to update you that, the embedded Arial font is subset and does not contain characters “H”, “A”, “N”, “K” and “S”. Chars are present, we are able to select them and copy, but we cannot see them because the glyph information in the current embedded font is absent for some characters. The characters will appear if we do not use the embedded font and it will be present on the system:
textFragment.getTextState().getFont().setEmbedded(false);
You can also embed all used fonts:
for(Font f:document.getFontUtilities().getAllFonts())
{
f.setEmbedded(true);
}
We hope this will be helpful. Please feel free to contact us if you need any further assistance.