问题
We are using javascript in PDFs to facilitate the automated creation of Goto page.. etc links, or based on certain keywords.
LIke this: this.pageNum = 2
This works fine, as long the PDF is opened inside a viewer that supports javascript.
I am now looking for a way, preferably i Java, to convert these annotations to real annotations, which will then be usable outside of Acrobat.
I have done quite some research on the net so far (i think. ,) - but couldnt find an approach how to go on with that.
回答1:
First and foremost, links containing JavaScript are real annotations.
Whether it is possible to convert depends a lot on the JavaScripts you attempt to convert. With very simple things like pageNum = x you may be able to find a replacement, but you will quickly run out of options, because the number of Actions available is rather limited.
But already a simple construct like setting the value of a document level variable (set in a document-level script):
var cameFrom ;
in the link or button you use to jump to another page
camefrom = this.pageNum ;
and have a button/link to jump back to where you came from
this.pageNum = camefrom ;
will be essentially impossible to solve programmatically.
You will also have to make many assumptions, which may work for your specific files.
来源:https://stackoverflow.com/questions/24173725/convert-javascript-links-in-pdf-to-real-annotations