Export an EPS from InDesign CS2

Since I am terrible at scripting, I had difficulty finding how to assign the transparency flattener preset when exporting an EPS. My guess is that the same id would work when exporting a PDF. I thought I would include this script for others, and maybe somebody could even improve upon it, so it can help others?

This script will export an EPS from the active InDesign document to the folder in which the original resided.

tell application "Adobe InDesign CS2"
	if (exists document 1) and (saved of document 1 is true) then
		set theDoc to active document
		set filePath to file path of document 1 as text
		set fileName to name of front document as string
		if fileName contains ".indd" then
			set aCount to count every character of fileName
			set aCount to aCount - 5
			set fileName to characters 1 thru aCount of fileName as string
			set fileName to word -1 of fileName as string
		end if
		display dialog fileName
	else
		display dialog "You must first save the file."
	end if
end tell

tell application "Adobe InDesign CS2"
	set theDoc to active document
	-------------------------
	-------------------------
	--This will convert all Spots to Process. Probably not necessary, nor preferred in most prepress situations.
	try
		set convert to process of every ink whose index > 4 to true
	end try
	-------------------------
	-------------------------
	
	tell EPS export preferences
		--set applied flattener preset to flattener preset, medium
		set origProperties to properties
		
		--It appears to me that low, medium, and high transparency flattener presets can be achieved by using their respective ids of, 110, 111, and 112. For this I am using medium.
		try
			set applied flattener preset to flattener preset id 111
		end try
		set properties to {data format:ASCII, PostScript level:level 2, OPI image replacement:false, omit bitmaps:false, omit EPS:false, omit PDF:false, EPS color:CMYK, preview:PICT preview, EPS spreads:true, font embedding:complete, image data:all image data, bleed bottom:0, bleed inside:0, bleed outside:0, bleed top:0}
		
	end tell
	export theDoc format EPS type to (filePath & fileName & ".eps") without showing options
	set properties of EPS export preferences to origProperties
end tell

Hi Jeff,

I don’t believe that the flattener id setting is constant, and wouldn’t specify it that way. Additionally, your convert all spots to process directive should go to the document. I made these and a couple other minor changes, below.

tell application "InDesign CS"
	if (exists document 1) and (saved of document 1 is true) then
		set theDoc to active document
		set filePath to theDoc's file path as text
		set fileName to theDoc's name as text
		tell fileName to if it contains ".indd" then set fileName to text 1 thru -6
	else
		display dialog "An error has occurred. Your document is either nonexistent or must be saved prior to continuing." with icon 2 buttons "Cancel"
	end if
	tell theDoc to set convert to process of every ink to true
		tell EPS export preferences
		set origProperties to properties
		set properties to {data format:ASCII, PostScript level:level 2, OPI image replacement:false, omit bitmaps:false, omit EPS:false, omit PDF:false, EPS color:CMYK, preview:PICT preview, EPS spreads:true, font embedding:complete, image data:all image data, bleed bottom:0, bleed inside:0, bleed outside:0, bleed top:0}
		set applied flattener preset to "[Medium Resolution]"
	end tell
	export theDoc format EPS type to (filePath & fileName & ".eps") without showing options
	set properties of EPS export preferences to origProperties
end tell

Marc. I cannot begin to tell you how grateful I am to you and so many others on this forum that have helped me tremendously. Your modifications to this script are perfect and they work!!! Thank you very much for your time and willingness to help.

-Jeff