Acrobat JavaScript - convert JavaScript page links to “real links”

筅森魡賤 提交于 2019-12-25 06:55:02

问题


The situation:
I have ~1,000,000 PDF files. I am using Acrobat JavsScript to search for certain keywords in each of the PDFs, and then give the keyword a link by setAction("this.pageNum = n"). The pageNum value, n, is generated by my script, too. The result is that the user can go to page number n directly by clicking the link.

The problem:
I do not want the links to trigger JavaScript actions. Instead, I want to them to be "real links". Each of the "real link" should point to the same page number as the JavaScript action does. The reason is that I want users to be able to use the links with a PDF reader that does not allow JavaScript (e.g. SumatraPDF or Chrome browser).

  • It would be ideal if the solution is implemented in Acrobat JavaScript, so that I can integrate into my script. If not possible,
  • It would also be great if the solution can be implemented in Python, since the problem is part of a larger Python application I am developing.
  • If still not possible, a solution in any programming language will suffice.

What I have tried:
I have looked up the entire "JavaScript for Acrobat API Reference". The Link object does not have a "go to page reference" property (unlike, using HTML as an analogy, the "a" tag has an "href" property). It seems to me that the Link object only allows setAction() method - but please correct me if I am wrong.

Similar question? Someone has asked a similar question, but both the question and answer was rather vague (no offense, please), so I'm asking again. Convert javascript links in PDF to real annotations


回答1:


At the end I used a script from this site:

http://try67.blogspot.de/2011/09/convert-javascript-links-to-real-web.html

Its a java tool which does exactly that - if you need a quick solution.

It seems that JAVA will be the approach to interpret the javascript inside the PDF. Pythons PDF does



来源:https://stackoverflow.com/questions/26908906/acrobat-javascript-convert-javascript-page-links-to-real-links

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