Export PDF from InDesign - multiple problems

Alright, this is driving me batty. All I want to do is applescript exporting a pdf. I keep encountering 3 problems that don’t seem to be answered in the guides. Here is the relevant script:

tell application “InDesign CS”
–configure pdf export settings
tell PDF export preferences
–general settings
set acrobat compatibility to acrobat 5
–other pdf settings (compression, etc)
–security settings
set use security to true
set change security password to “SHPS”
set disallow extraction for accessibility to false
set disallow document assembly to false
set disallow form fill in to false
set disallow notes to true --turn off commenting
set disallow copying to true
set disallow changing to true
end tell
–export the active document as pdf
tell active document
set docName to full name & “.pdf”
export myDoc to file docName format “Adobe PDF”
end tell
–close the active document
close active document
end tell

First, when you set acrobat compatibility to 5, it doesn’t work. When I open the resulting pdf, it says can be opened with 3. Yet when I export manually it says it can be opened with 5 - like it should.

Second, the security settings don’t seem to work. I can set disallow copying to true but that turns off extraction for compatibility and setting that to false will not turn it on. Other security settings are equally baffling. I cannot figure how to have all changes not allowed, commenting not allowed but still have filling in of form fields allowed. Again, this all works when you do it manually.

Finally, the line

export myDoc to file docName format “Adobe PDF”

should export the pdf to the path/filename stored in docName. Instead I get this error:

InDesign CS got an error: Can’t make some data into the expected type.

The only way I can get the export line to work is to use export to file and manually enter the path and file name followed by the format. In the scripting guide it just says export to, without file. I get an error every time I try it like that, even when I manually enter the location. Any help would be greatly appreciated.


I’m not sure on this one, but shouldn’t the export line look like:

export myDoc to file docName format "pdf type" 

Set it up in the UI so it’s working, and then get the properties.

Your mistake is in the line before: full path is returning an alias, so docName contains a list of an alias and the string “.pdf”. This should be evident from the log.

– Shane Stanley

When I try the script I get “myDoc variable not defined”?? Where in the script did you define myDoc?

I ran your security settings with a different script written to export PDFs and the script in general worked and applied your settings but the acrobat compatibility setting still came back with “open as version 3” as you said.

In playing with this I was also wondering if there was a way to auto enter the Author information on these documents. I can’t find how to reference it in the script from InDesign and I’m wondering if it has to be done as a next stage in Acrobat itself… but still couldn’t find a reference in the dictionary to change that.