Adobe Acrobat Pro XI - Adding Javascript to a PDF
Asked Answered
H

1

8

This may seem like a really novice question, but I have been tearing my hair out all day on this.

I am running the trial version of Adobe Acrobat Professional XI I am looking to add simple JavaScript to a PDF file.

The aim is to have a PDF file, that when opened, pops up with an alert message with Yes and No options. Click Yes, and the alert goes away, leaving the PDF to be read. Click No, and the file closes.

The main trouble I am having is where to write my code. I have used the JavaScript Debugger but it is not very intuitive, and doesn't seem to let me add JavaScript to the file, only run from within the debugger.

All the tutorials I have looked at online show me the code, but not where to write it.

Hypogeous answered 19/6, 2014 at 13:15 Comment(1)
The places where to attach JavaScripts in a PDF are many, and it might therefore be a good idea to look at the documentation. The Acrobat JavaScript documentation is part of the Acrobat SDK, downloadable from the Adobe website.Serpasil
P
6

In Adobe Acrobat open Tools pane on the right, select JavaScript section and then Document JavaScripts.
Enter a script name and click Add. In the JavaScript editor remove the generated code and add yours:

app.alert({cMsg: "JavaScript action: hello", cTitle: "demo title"});

This code (if not placed in a function) will be executed automatically when the document is opened.

Parakeet answered 19/6, 2014 at 15:22 Comment(2)
In the tools pane to the right, I only have 'Content Editing', 'Pages', 'Interactive Objects', 'Forms', 'Action Wizard', 'Text Recognition' and 'Protection'. Where am I going wrong?Hypogeous
No worries found it! I clicked on the little button on the top right of thisHypogeous

© 2022 - 2024 — McMap. All rights reserved.