Copy link to clipboard
Copied
I'm working on a single page pdf that includes a large number of buttons. I have been trying to write a script that will export a text file containing only the name of the button clicked. I'm going to embed the script in each button and use the mousedown event to trigger it.
I'm experiencing two problems:
Thanks in advance. I'm sorry about how vague my questions are, but I don't have access to acrobat at the moment.
Copy link to clipboard
Copied
We can't help without seeing the script.
Copy link to clipboard
Copied
You should have all the information you need to fix the problem based on the error message. Something is not available when it's required.
As to initializing the script when the document is opened: Create a document level script (call it e.g. "initialization"). When the editor comes up, it will have a function stub in it. Remove that and add your initialization code. Document level scripts are executed when the file is opened. You may also want to consider putting your code that you need to execute in every button into a document level function and then only call that function from each button - with a parameter that indicates what button was pressed. The "event" object does contain that information. You can e.g. pass event.target.name to the function and then have the button name available in your document level function.
Copy link to clipboard
Copied
It is possible when using the JavaScript console to introduce new variables or functions that remain persistent until all the currently open PDFs are closed or Acrobat/Reader is closed. This will cause a PDF form or script that works fail the next time Acrobat/Reader is opened.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now