Scope: Acrobat Professional 6.0 and greater
Skill Level: Beginner
Prerequisites: Familiarity with Acrobat Professional
Document Actions are JavaScript events triggered by printing, saving, and closing the PDF. These Actions give developers the opportunity to change the PDF before and after one of these activities (except for closing). Some uses for these actions are making a stamp visible before printing, changing a date field before saving, or shutting down a timer when the document is closed.
To edit or create a Document Action script, use the menu item:
Advanced>JavaScript>Set Document Actions …
This menu item displays the Document Actions Dialog (Figure 1). There are 5 Document Actions displayed in the list on this dialog.
Action | Description |
Will Close | Triggered immediately before the PDF is closed. Used mainly for clean up; Ex: killing timers and multimedia displays. |
Will Save | Triggered immediately before the PDF is saved. Used mainly to make automatic changes to the PDF so the saved document is unique. |
Did Save | Triggered immediately after the PDF is saved. Used mainly to restore changes made to the PDF in the Will Save Action. |
Will Print | Triggered immediately before the PDF is printed. Used mainly to make visual changes to the PDF, such as making a stamp or header visible. |
Did Print | Triggered immediately after the PDF is put on the print queue. Used mainly to restore changes made to the PDF in the Will Print Action. |
If one of the Actions contains a script, a green dot will appear to the left of the list entry. In Figure 1 the Will Close Action is marked as having a script, and the first few lines are displayed at the bottom of the dialog.
There is no Did Close Action. After the document is closed, everything on the document is unavailable to the JavaScript Engine. What context would such a script operate in? It would not be able to use or change anything about the document since it’s already closed.
It may also occur to some readers that the Will Close Action could be used to hide changes in the PDF (by setting doc.dirty property to false) so that Acrobat never asks the user if they want to save the document. You can’t do this! The Will Close Action happens after this dialog is displayed.
Products covered: |
Acrobat XIAcrobat XAcrobat 9 |
Related topics: |
JavaScript |
Top Searches: |
Edit PDF create PDF Action Wizard |
Try Acrobat DC
Get started >
Learn how to
edit PDF.
Post, discuss and be part of the Acrobat community.
Join now >
0 comments
Comments for this tutorial are now closed.
Comments for this tutorial are now closed.