I have a PDF, which I think has JavaScript embedded in it. Is it possible to see what that JavaScript is? And if so, how would I see it?
It's probably possible to hack something together with iText, but I would prefer something faster.
If you prefer a fast method, just open the PDF with a text editor, e.g. NotePad++, and search on JavaScript.
In my case, I ran into a pdf that insisted on being printed instead of viewed. With NP++ I found this script:
<</S/JavaScript/JS(this.print\({bUI: true,bSilent: false,bShrinkToFit: true}\);this.closeDoc\(\);)>>
The notation is a little weird, but obviously it has a Print command, followed by a Close command.
You can even replace the Close command with spaces, which is easy in Overwrite mode (press the Insert key to toggle to and from Overwrite mode). You need to keep the total nr of characters the same, to preserve the offset pointers in the PDF. Then, the document can be viewed after cancelling the print command.
As it was a digitally signed document, of course the signature showed "invalid" :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With