Convert javascript links in PDF to real annotations

旧时模样 提交于 2019-12-13 05:04:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!