InDesign CS4 modifying PDF export preferences

I am not sure why this happens based on this sequence of events.

If I manually export a PDF from Indd CS4 and change it’s Preset to “PDF/X-1a:2001”, the PDF honors the settings (as it should).

Then if I export using the below script it appears to hold the new “color bitmap sampling” preference change included in the script, but it is not honoring the other settings included within the preset of “Smallest File Size”.

But if I run the script once more, then it all works. For example, the color space is now RGB and the images are not sampled down.

Technically I only want to be able to output a PDF from InDesign (regardless of embedded images) to an RGB color space. Using the code below is the closest I got. But I am hesitant about the issue if somebody exports to another preset prior to executing this script.

Can anybody help make these changes stick every time?

set theName to "Exported.pdf" as text
set myDesktop to (path to desktop as text)



tell application "Adobe InDesign CS4"
	activate
	set oldProps to properties of PDF export preferences
	set theProps to properties of PDF export preset "[Smallest File Size]"
	set newProps to {view PDF:false, color bitmap sampling:none} & theProps
	set properties of PDF export preferences to newProps
	export active document format PDF type to (myDesktop & theName) without showing options
	set oldProps to properties of PDF export preferences
end tell

I’ve read before about such problems when using AppleScript to export to PDF from InDesign. What I do is create .joboptions files and save them into the Ressources folder of a bundle AppleScript application. The script will first instruct the Finder to check if the needed files exists on the user’s computer. If they aren’t there, the script will copy the needed files and just carry on with the “export format PDF type” command in InDesign defining destination and the good .joboptions file to use. I have multiple users using this script with no problem so far.

–code to check/copy needed files from Ressources folder of AppleScript bundle application
set app_path to (path to me) as string
set export_swop_joboption to alias (app_path & “Contents:Resources:Export SWOP.joboptions”)
set export_newsprint_joboption to alias (app_path & “Contents:Resources:Export NEWSPRINT.joboptions”)
set profil_swop to alias (app_path & “Contents:Resources:SWOP2006_Coated3v2.icc”)
set profil_news to alias (app_path & “Contents:Resources:ISOnewspaper26v4.icc”)
set current_user_path to (path to current user folder)
set current_disk to (path to startup disk)
set adobe_joboptions_folder to (current_user_path & “Library:Application Support:Adobe:Adobe PDF:Settings:” as string)
set adobe_colorprofile_folder to (current_disk & “Library:Application Support:Adobe:Color:Profiles:Recommended:” as string)
tell application “Finder” to exists (adobe_joboptions_folder & “Export SWOP.joboptions”)
if the result is false then tell application “Finder” to duplicate export_swop_joboption to adobe_joboptions_folder with replacing
tell application “Finder” to exists (adobe_joboptions_folder & “Export NEWSPRINT.joboptions”)
if the result is false then tell application “Finder” to duplicate export_newsprint_joboption to adobe_joboptions_folder with replacing
tell application “Finder” to exists (adobe_colorprofile_folder & “SWOP2006_Coated3v2.icc”)
if the result is false then tell application “Finder” to duplicate profil_swop to adobe_colorprofile_folder with replacing
tell application “Finder” to exists (adobe_colorprofile_folder & “ISOnewspaper26v4.icc”)
if the result is false then tell application “Finder” to duplicate profil_news to adobe_colorprofile_folder with replacing

–rest of script…

Thank you Stefcyr, this is a very good solution to my issue. I appreciate you responding with your script and advice. Have a great weekend.

-Jeff

G’day Jeff

You may find you’re confusing things with the line :

   set newProps to {view PDF:false, color bitmap sampling:none} & theProps

which ‘view PDF’ and ‘color bitmap sampling’ settings should it honor? theProps, or newProps

This is the way I do it, and I’ve not noticed any problems :

tell application "Adobe InDesign CS4"
	activate
	set oldProps to properties of PDF export preferences
	set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]" --set the basic property preset first
	set view PDF of PDF export preferences to false --then alter the individual properties that differ from the preset
	set color bitmap sampling of PDF export preferences to none
	export active document format PDF type to (myDesktop & theName) without showing options
	set properties of PDF export preferences to oldProps
end tell

Notice also that I’ve changed your last line ” assuming that you’re trying to reset the preferences back to where they were before running the script (?)

Hope this helps

d.

Thank you d. for pointing out some issues I needed to fix. However your code still runs into the same issue I am having.

For example I am curious what would happen if you tried the following. Create an InDesign CS4 document with some text with a gradient fill and some effects, like a drop shadow. (or use the file in the link I have attached.) Then manually (choosing File>Export PDF" and export using a preset such as PDF/X-1a. Then open that file in Illustrator CS4 and you will you will notice the color space is CMYK.

Then right after open the same InDesign file and export using your script. Open that file in Illustrator and the color mode is still CMYK.

The only way I can get the file to not revert back to using CMYK, is to have the script export the file twice in the script. More specifically the script needs to reset the PDF properties “twice”. I really don’t understand why this is, but I have tested it on this file numerous times.

http://dl.dropbox.com/u/89164/Logotron3K.indd.zip

tell application "Adobe InDesign CS4"
	activate
	set myDesktop to (path to desktop as text)
	set theName to "exportedPDFxyz.pdf"
	set oldProps to properties of PDF export preferences
	set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]" --set the basic property preset first
	set view PDF of PDF export preferences to false --then alter the individual properties that differ from the preset
	set color bitmap sampling of PDF export preferences to none
	export active document format PDF type to (myDesktop & theName) without showing options
	set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]" --set the basic property preset first
	set view PDF of PDF export preferences to false --then alter the individual properties that differ from the preset
	set color bitmap sampling of PDF export preferences to none
	export active document format PDF type to (myDesktop & theName) without showing options
	set properties of PDF export preferences to oldProps
end tell

That’s weird,

I’m not seeing that at all. But I’m trying to replicate what you’re doing with CS2 ” text gradients, dropshadows, etc.
PDF-X1a = CMYK, then script version immediately after = RGB.

I’ll run another test when I get a chance at work using CS4 (and your file) ” and let you know what I get.

d.

G’day Jeff

I tested this with CS4 today and found the same as you. It’s weird that it works correctly in CS2, but not CS4.
I also tested a simple file with just a linked logo and got the same results.

But you don’t need to export the PDF twice. It’s enough to simply repeat the ‘set properties’ line. Or you can force the color space to RGB. That is, activate either of the two commented lines in this version (at least, this works on my machine) :

set theName to "Exported.pdf" as text
set myDesktop to (path to desktop as text)
tell application "Adobe InDesign CS4"
	activate
	set oldProps to properties of PDF export preferences
	set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"
	--set properties of PDF export preferences to properties of PDF export preset "[Smallest File Size]"
	set view PDF of PDF export preferences to false
	set color bitmap sampling of PDF export preferences to none
	--set PDF color space of PDF export preferences to RGB
	export active document format PDF type to (myDesktop & theName) without showing options
	set properties of PDF export preferences to oldProps
end tell

I’ve no idea why repeating the ‘set properties’ line works, but stating it once doesn’t ” very strange behaviour (?)

Good luck with it Jeff

d.