Skip navigation
Currently Being Moderated

Help- JS script to enable security

Jun 26, 2009 11:51 AM


I am not quite sure if this is even possible- I need to have a script that will activate security in a PDF (require password for editing/extracting content, OK to print high res) and generate a random password, and resave the file. It of course can't re-ask to have the password entered by hand, as no one will know the random password, it has to all get set programatically.

I need to integrate this in an Applescript that will combine a couple non-secure files into a secure file. I'm fine with the Applescript part but don't have a knowledge of javascript.

Any examples or code/snippets is appreciated!



  • Currently Being Moderated
    Jun 27, 2009 12:50 AM   in reply to SuperMacGuy

    Not possible with Acrobat JavaScript.

    Mark as:
  • Currently Being Moderated
    Jun 30, 2009 1:56 PM   in reply to SuperMacGuy

    As Bernd said, not possible, as I found out also, so I decided to use Security Policies
    and have javascript called via do script, careful though as this may fail using 10.5.7  Intel AppleScript 2.0.1, see threads below

    this script was suggested to me and works great under 10.4.11 Applescript 1.10.7 Acrobat 8.1.3

    Just change the "NAME OF YOUR SECURITY POLICY HERE" to the name of your policy.

    set Default_Path to (path to desktop as Unicode text)

    set PDF_Security to "var policyArray = security.getSecurityPolicies(); for (var i = 0; i < policyArray.length; i++) {if (policyArray[i].name == 'NAME OF YOUR SECURITY POLICY HERE') { var myPolicy = policyArray[i]}} this.encryptUsingPolicy( myPolicy );"

    tell application "Adobe Acrobat Professional"
        tell active doc
            set File_Name to name
            do script PDF_Security
            if modified is true then
                save to file (Default_Path & File_Name) -- Save as required… For Certified Document
            end if
        end tell
    end tell


    Mark as:
  • Currently Being Moderated
    Jul 1, 2009 9:15 AM   in reply to Kevin Parrott



    I tried and erred about this problem, until yesterday.

    This script seems to work very well.

    my environment :

    - Mac Pro Quad 3GHz

    - Mac OS X 10.5.7

    - AppleScript's version : 2.0.1

    - Acrobat 9 Pro (9.1.2)


    Thank you!



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points