script for converting pdf to eps in acrobat

Thanks again, works like a charm.
I ended up with this script:

set thefolder to choose folder with prompt "Source Folder?"
set targetFolder to choose folder with prompt "Destination Folder?"


tell application "Finder"
	set newFileList to {}
	set filelist to every item of entire contents of thefolder
	repeat with myFile in filelist
		if name of myFile ends with ".pdf" then
			set end of newFileList to myFile
		end if
		
		
		try
			set oldTID to AppleScript's text item delimiters
			set AppleScript's text item delimiters to ":"
			set docName to last text item of (myFile as string)
			set AppleScript's text item delimiters to oldTID
			
			set oldASTID to AppleScript's text item delimiters
			set AppleScript's text item delimiters to ".pdf" -- the string to search for
			set tempString to text items of docName
			set AppleScript's text item delimiters to ".eps"
			set docNameToSaveTo to tempString as string
			set AppleScript's text item delimiters to oldASTID
			
			--set docNameToSaveTo to ("EPS_" & docName) as string
			set docToSavePath to (((targetFolder as string) & docNameToSaveTo) as string) --as alias
			
			tell application "Adobe Acrobat Pro"
				open myFile --as alias --with invisible
				set actDoc to active doc
				tell application "Adobe Acrobat Pro" to save actDoc to file docToSavePath using EPS Conversion --with embedded fonts, halftones and TrueType without binary, annotation, images and preview
				close actDoc saving no
			end tell
		on error errMsg number errNum
			(errNum & " : " & errMsg) as string
		end try
		
	end repeat
end tell

Good. Glad to know it works. :wink:

a bit easier


set thefolder to choose folder with prompt "Source Folder?"
set targetFolder to (choose folder with prompt "Destination Folder?") as text


tell application "Finder" to set filelist to every item of entire contents of thefolder
repeat with myFile in filelist
	set {name:fileName, name extension:fileExtension} to myFile
	if name extension of myFile is "pdf" then
		try
			set docNameToSaveTo to text 1 thru -5 of fileName & ".eps"
			set docToSavePath to targetFolder & docNameToSaveTo
			tell application "Adobe Acrobat Pro"
				open file (myFile as text)
				save document 1 to file docToSavePath using EPS Conversion --with embedded fonts, halftones and TrueType without binary, annotation, images and preview
				close document 1 saving no
			end tell
		on error errMsg number errNum
			display dialog "An error occurred: " & errNum & " - " & errMsg buttons {"Cancel", "OK"} default button "OK"
		end try
	end if
end repeat


Thanks Stefan, I’ll give that a try. I appreciate your help.

I’m trying to do the same thing with saving to Postscript (ps). I don’t see in the code anywhere to set the postscript level to 2, although the op had that in their code.

You must be using an old RIP to need Level 2… If you look at Acrobat’s Applescript dictionary, under EPS conversion, there is a option to set the postscript level :

postScript level (integer) : The PostScript Language Level. Levels 2 and 3 are supported, but not Level 1.

I don’t think you’re gonna have plain PS. EPS should work as well as PS, Distiller should accept them, if that’s what you’re using.

But why use PS? Or EPS for that matter? PDF is much, much better and modern, plus supports native transparency. I don’t see the need for a format that’s no longer supported, unless you’re using very old RIPs or apps.

level 2 seems to be the default level


tell application "Adobe Acrobat Pro"
	set psLevel to postScript level of conversion "com.adobe.acrobat.ps" --> 2
end tell

Thanks.

The only issue I had with your script was that it went too fast, so that the names of one file were being applied to the name of a different output file. I’ll try to figure that out another time.

P.S. The reason to output as ps, is that was the only way to get the pdf file to a reasonable size. For some reason, optimized just added to the file size, even after checking all the options and leaving images to downsize to 150 whle embedding subsets. Reduce file size pdf only reduced it by less than 1 MB. Put when I saved the pdf as a postscript and redistilled it at the smallest file size preset, I got a reduction of about 40%.

I see. I’ve seen that before. Main reason is, there is a lot more junk in PDF than there was in a PS. I use the optimize command inside Acrobat, but Acrobat being severely limited in its Applescript dictionary, there seem to be no way to automate this, I’ve looked. I abandonned quickly though, sizes of PDF files never been an issue yet.

Changing the resolution of images when creating the PDF does not remove a lot of junk that seem to be useless, as when it is removed with Acrobat, it still works just fine.

Converting from CMYK to RGB helps always, cropping images to frames also. Have you tried lowering the version of the PDF file when it’s created? 1.4 should be a minimum.

As for the script going too fast, that is surprising. I’ve never had that problem before in similar scripts.