Document Level Scripts With Acrobat Standard

If you are using Adobe Acrobat Standard, you’ve probably noticed that you cannot add document level scripts to PDF documents. This is a limitation of the user interface, Acrobat Standard can actually add such scripts (and document actions), but it requires some JavaScript programming.

I’ve done that job for you. Download the script addDocumentScripts.js¬†and save it on your local computer.

To install the script, use the information from my post “Acrobat JavaScripts – Where do they go”

Once the file is saved in either the application or the user level JavaScripts directory, you can open a PDF file and select the new menu item “File>Add JS Scripts”.

This will bring up the following dialog:

Add Document Scripts Dialog

First select what type of script you want to add (the default is “Document Level”):

  • Document Level Script
  • Document Action:
    • Will Close
    • Will Save
    • Did Save
    • Will Print
    • Did Print

The script name is only necessary for a document level script, the document actions do not require a name (there can only be one per type).

When you fill in the script, make sure you paste from your text editor: Edit the script in an editor and then just paste the final script, do not edit the script in this dialog. The reason for this is that you will not be able to retrieve the script with Acrobat Standard, only Acrobat Pro allows you to do that. This means that any changes you make to your script in the input field on this dialog will be lost – they will be saved in the document, but you will not be able to retrieve or to edit them.

This is not the most elegant way to add scripts to a document, but if all you have is Acrobat Standard, at least you can.

This entry was posted in Acrobat, JavaScript, PDF and tagged , , . Bookmark the permalink.

14 Responses to Document Level Scripts With Acrobat Standard

  1. Nkosinathi Makhaye says:

    Hi my name is Nkosinathi Makhaye my comment is if the adobe can be made easy to download I think that would be a good idea a specially for those who find so difficult to following the instrutions like me of wich its not only me is many of us out there thank you.

  2. Karl Heinz Kremer says:

    Nkosinathi, unfortunately I don’t understand your question. What would you like to be easier to download?

  3. JT says:

    This is fantastic, thank you for sharing. Just a quick question on how this works with the system, how do you make changes/corrections to a document level script that is added this way? Can you just add a corrected version provided you use the same script name or do you need to start over with the file prior to adding the document level script.

  4. Karl Heinz Kremer says:

    You can just replace a script with a new script with the same name.

  5. Balgad says:

    Amazing! I’ve searched so much for a solution and now this works! Btw, sometimes does not update the document-level script in spite of I replace the script with the same name. But after some tries (save, reopen in reader, etc) it works again.

    So this is really cool!

    Thanks

  6. Pep says:

    Hi Karl,
    I followed all your steps, but I’m not able to save the script for document-level. Could you please provide an example?

  7. Karl Heinz Kremer says:

    Pep, you can for example put the following one line script into a document level script to see the effect:

    app.alert("Document Level Script");

    This will display a message box when the PDF gets loaded in Adobe Acrobat or Reader.

  8. GP says:

    I have tried pasting a simple app.alert but it is not working. The script name is zzformdocopen.

  9. Karl Heinz Kremer says:

    GP, as I’ve reported in an email to you, the problem is a bug in my code, and I’ve updated the linked script. Thanks for bringing this to my attention.

  10. GP says:

    Is there a character limit to a document level script?

  11. Karl Heinz Kremer says:

    GP, I am not aware of one.

  12. Marc says:

    Is there a way to write a script for an Acrobat Action that will place a Document Level Script in Acrobat DC? I’ve been searching the SDK and Google but no luck yet.

    I was thinking there should be some way to use the setAction(); method but not sure if that’s an option…

    What I’d like is to add default variables for some text fields on the document level to be used by several fields.

  13. Marc says:

    Thanks Karl. That works great!

Leave a Reply

Your email address will not be published. Required fields are marked *