Error when editing a pdf and opening it in IE11

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.

@qumer

Thank you for contacting support.

We have worked with the data shared by you but the issue is not reproduced with Aspose.PDF for Java 18.12. Please upgrade to latest version because it includes more features and bug fixes. The PDF file generated using below code snippet has been attached for your kind reference outputPdf_18.12.pdf.

Document pdfDocument = new Document(dataDir + "myPdf.pdf");
PageCollection collection = pdfDocument.getPages();
for (Page page : collection) {
    page.getContents().add(new com.aspose.pdf.operators.GSave());
    TextFragmentAbsorber absorber = new TextFragmentAbsorber("[Mention2]");
    page.accept(absorber);
    TextFragmentCollection textFragmentCollection = absorber.getTextFragments();
    for (TextFragment textFragment : textFragmentCollection) {
        textFragment.setText("AnotherText");
    }
}
pdfDocument.save(dataDir + "outputPdf_18.12.pdf");
pdfDocument.close();

We hope this will be helpful. Please feel free to contact us if you need any further assistance.