I want to make a link in a PDF file that when clicked on changes the text of the link. In HTML with JavaScript you can do that with the innerHTML
property of the link. Is the开发者_如何学Cre an analog in JavaScript for PDF?
You can't alter PDF files with JavaScript. :(
The answer is no, and the reason has to do with the specifications of links in PDF vs. HTML. In an HTML file a link is part of the document tree, and the text of the link is one of its children. In a PDF file a link is a "hot" rectangle on the page that does something when the user clicks in it. The link may surround some text but as far as the document is concerned that's a coincidence.
The way I found to have dynamic data in a PDF file is to use form fields. Those can change their contents on mouse events. By default form fields look different than the regular document text but in my case that was not a problem.
精彩评论