Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Apr 12, 2021 7:43 pm

Hi!!

I'm trying to remove script embedded in PDF.

I have a PDF file taht when I open, this automatically open a webpage en IExplorer browser.

I need to remove using java, maybe Spire have a function to do this.

Thanks for help! :-)

Regards.

riturra84
 
Posts: 4
Joined: Fri Apr 09, 2021 10:02 pm

Tue Apr 13, 2021 11:01 am

Hi,

Thank you for your feedback.
Please refer to the following code to achieve your requirement, if it has no help, please provide your sample PDF document for further investigation. You could attach it here or send to us via email ([email protected]).
Code: Select all
 
        String input = "OpenAction.pdf";
        String output = " removeOpenAction.pdf";

        //create a pdf document
        PdfDocument document = new PdfDocument();

        //load an existing pdf from disk
        document.loadFromFile(input);

        //remove action
        document.setAfterOpenAction(null);

        //save the document
        document.saveToFile(output, FileFormat.PDF);


Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Apr 13, 2021 2:15 pm

Thank you Annika!

I test the code but still not working.

The PDF file is in attached GoogleOpenAction.rar, this PDF open google on browser when I open it on Adobe Acrobat Reader.

Regards.

riturra84
 
Posts: 4
Joined: Fri Apr 09, 2021 10:02 pm

Wed Apr 14, 2021 10:11 am

Hello,

Thank you for your feedback. I tested the document you provided and indeed found the action can't be removed. This issue has been logged into our Bug tracking system with the ticket SPIREPDF-4194. Our development team will investigate and fix it. Once it is resolved, I will inform you. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Apr 29, 2021 11:12 am

Hello,

Glad to inform you the reported issue SPIREPDF-4194 has been resolved. Please download the hotfix Spire.PDF for Java Version:4.4.8 from the following link and use the below code to remove javascript from PDF document.
https://www.e-iceblue.com/Download/pdf-for-java.html
Code: Select all
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile(input);
pdf.removeDocumentJavaScript();
pdf.saveToFile(output, FileFormat.PDF);

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Apr 29, 2021 6:49 pm

It works!! :D

Tahnk you so much, have a good day!

riturra84
 
Posts: 4
Joined: Fri Apr 09, 2021 10:02 pm

Fri Apr 30, 2021 1:52 am

Hello,

Thank you for your feedback.
If you have other questions about using Spire.PDF in the future, please feel free to contact us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF