Secured PDF from Illustrator CS6

I’ve been banging my head against the wall on this for awhile and I can’t figure out what I’m missing. My script updates the filename and date on an Illustrator file and exports a secured PDF that will not allow anyone to edit or print the pdf. I can get it secured and but I can not figure out how to disable printing.

Here is my scritp as it stands:


-- System Date
tell (current date) to get (it's month as integer) & "/" & day & "/" & (it's year as integer)
set mgDate to the result as string

tell application "Adobe Illustrator"
	
	-- Filename
	tell application "Adobe Illustrator" to set mgName to (name of document 1)
	set theFilePath to file path of document 1 as string
	
	set the oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ":"
	set thePathItems to text items of theFilePath
	set AppleScript's text item delimiters to the oldDelims
	set parsedPath to items 1 thru ((count of items of thePathItems) - 1) of thePathItems
	set AppleScript's text item delimiters to ":"
	set parentPath to parsedPath as string
	set AppleScript's text item delimiters to the oldDelims
	
	set text item delimiters of AppleScript to ""
	if mgName contains ".ai" then
		set aCount to count every character of mgName
		set aCount to aCount - 3
		set mgName to characters 1 thru aCount of mgName as string
		set mgName to mgName as string
	end if
	
	set savePDFPath to parentPath & ":" & mgName & ".pdf"
	
	-- Date
	set contents of text frame "date" of document 1 to mgDate
	set contents of text frame "filename" of document 1 to mgName
	
	--PDF Save Options
	set pdfSaveOptions to {class:PDF save options, compatibility:Acrobat 8, enable access:false, require doc password:true, require perm password:true, preserve editability:false, permission password:"Test", allow printing:pdf 40 print none, changes allowed:pdf 40 no changes, enable copy:false}
	save current document in file savePDFPath as pdf with options pdfSaveOptions
end tell

It will create the pdf and it is secured but the printing is still enabled and I can’t figure out how to disable it. Any help would be greatly appreciated.

The security panel in Acrobat showing that printing is still allowed. All I want the end user to be able to do is view the pdf.

Hi and welcome to macscripter

try using a preset, iv’e found them to be way more reliable and easier to change

save current document in file savePDFPath as pdf with options {class:PDF save options, PDF preset:"YOUR PDF PRESET"}
close current document saving no  --or yes

looking at some old scripts I have, it looks like (correct me if i’m wrong), you need to apply the security setting
directly to the PDF (after it has been created), some one helped me out ages ago with this code below, I had to create
a security policy in acrobat first Acrobat/Edit/Protection/Manage Security Policies then use the below code to apply it to the PDF, replace “SECURITY POLICY NAME” with the name of your security 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 == 'SECURITY POLICY NAME') { var myPolicy = policyArray[i]}} this.encryptUsingPolicy( myPolicy );"

tell application "Adobe Acrobat Pro"
	activate
	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
			close
		end if
	end tell
end tell

Have you tried all the other print options? Those are some pretty arcane enumerations there. And, sometimes there are errors in implementation- one setting might be the opposite! (There was a bug in Indesign PDF preset for years that was the opposite of what it was declared to do).

I’ve got CS5 and I can’t get the file path to return a workable result so I can’t test this.

But, here’s a piece of shorter code:

if mgName contains ".ai" then
		set mgName to (characters 1 thru -4 of mgName) as string
	end if

I would rather get Illy to work on this than try Acrobat scripting. Acro scripting is a train wreck of old timey proportions.