开发者

How can I change the link text of a PDF Link with JavaScript?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜