Hi,
I am using aspose to change the text of a textFragment in a pdf, and when I do it usually works fine but sometimes I get an error when opening the pdf with Internet Explorer 11.
I am using Aspose.pdf version 11.9.0 with java 6.
Here is my code :
ClassLoader classLoader = getClass().getClassLoader(); InputStream file = classLoader.getResourceAsStream("sample/myPdf.pdf"); Document pdfDocument = new Document(file); PdfContentEditor contentEditor = new PdfContentEditor(pdfDocument); contentEditor.replaceText("[Mention2]", "AnotherText"); pdfDocument.save("outputPdf.pdf"); pdfDocument.close(); file.close();
I also tried this code and I get the same problem :
ClassLoader classLoader = getClass().getClassLoader(); InputStream file = classLoader.getResourceAsStream("sample/myPdf.pdf"); Document pdfDocument = new Document(file); PageCollection collection = pdfDocument.getPages(); for (Page page : collection) { page.getContents().add(new Operator.GSave()); TextFragmentAbsorber absorber = new TextFragmentAbsorber("[Mention2]"); page.accept(absorber); TextFragmentCollection textFragmentCollection = absorber.getTextFragments(); for (TextFragment textFragment : textFragmentCollection) { textFragment.setText("AnotherText"); } } pdfDocument.save("outputPdf.pdf"); pdfDocument.close(); file.close();
Also the problem only happens if I try to edit the tag that says “[Mention2]”, if I try to edit “[Mention1]” or any other text in the pdf the error doesn’t happen.
Here is the pdf I am trying to edit :
myPdf.pdf (131.9 KB)
Here is the pdf I get that doesn’t work with IE 11 :
outputPdf.pdf (160.8 KB)
Thank you for your help.