Set PDF save options in Adobe Illustrator CC2014

Hi peoples!

I try to save Illustrator Ai/EPS files as PDF with different options like as:


-- i try to set options for color/grayscale compression 

if chkImagesCompression as text = "Minimum" then
				set myCompression to "automatic JPEG minimum" as text
			else if chkImagesCompression as text = "Low" then
				set myCompression to "automatic JPEG low" as text
			else if chkImagesCompression as text = "Medium" then
				set myCompression to "automatic JPEG medium" as text
			else if chkImagesCompression as text = "High" then
				set myCompression to "automatic JPEG high" as text
			else if chkImagesCompression as text = "Maximum" then
				set myCompression to "automatic JPEG maximum" as text
			end if
...
-- then i try substitute variable myCompression to save options
save current document in file pdfName as pdf ¬
								with options {class:PDF save options, compatibility:Acrobat 5, preserve editability:false, color compression:myCompression, color downsampling:filesResolution, color downsampling threshold:(filesResolution + 24 as integer), color resample:bicubic downsample, grayscale compression:myCompression, grayscale downsampling:filesResolution, grayscale downsampling threshold:(filesResolution + 24 as integer), grayscale resample:bicubic downsample, bleed link:false, optimization:true}

And got an error “ “Error in exportPDF: -1700. Adobe Illustrator got an error: Can’t make some data into the expected type.”

But if i write as “color compression:automatic JPEG medium,” all work well. What should i do for solve that issue?

Hi,

the compression values are enumerated constants, not text. The difference is: no double quotes.
Try this


	if chkImagesCompression as text = "Minimum" then
		set myCompression to automatic JPEG minimum
	else if chkImagesCompression as text = "Low" then
		set myCompression to automatic JPEG low
	else if chkImagesCompression as text = "Medium" then
		set myCompression to automatic JPEG medium
	else if chkImagesCompression as text = "High" then
		set myCompression to automatic JPEG high
	else if chkImagesCompression as text = "Maximum" then
		set myCompression to automatic JPEG maximum
	end if

Hi, Stefan!

i think we can’t do:

set me Comression to automatic JPEG minimum

without conclusion this expression in quotes.

Syntax error: Expected end of line but found identifier.

If the value is expected to be an enumerated constant (actually an integer) it cannot work in quotes

Alex,

As well as what Stefan says, you need to do it inside an AI tell block.

I searched in the Internet and found :
https://wwwimages2.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2015/Illustrator%20Scripting%20Reference%20-%20AppleScript.pdf

In this well done document I found :

grayscale compression : Valid values:
automatic JPEG high, automatic JPEG low, automatic JPEG maximum, automatic JPEG medium, automatic JPEG minimum, automatic JPEG2000 high, automatic JPEG2000 lossless, automatic JPEG2000 low, automatic JPEG2000 maximum, automatic JPEG2000 medium, automatic JPEG2000 minimum, none

My understanding is that these are value making sense only in a tell application “Adobe Illustrator” block.
So I guess that the code below, in fact, stefan’s one encapsulated in the named block will compile.

tell application "Adobe Illustrator"
   if chkImagesCompression as text = "Minimum" then
       set myCompression to automatic JPEG minimum
   else if chkImagesCompression as text = "Low" then
       set myCompression to automatic JPEG low
   else if chkImagesCompression as text = "Medium" then
       set myCompression to automatic JPEG medium
   else if chkImagesCompression as text = "High" then
       set myCompression to automatic JPEG high
   else if chkImagesCompression as text = "Maximum" then
       set myCompression to automatic JPEG maximum
   end if
end tell

Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) mardi 29 septembre 2015 14:12:33

Ok, thanks, peoples :slight_smile:

It’s work. I don’t think about do this inside “tell Illustrator”…

I’m glad I have not yet got to the expression set acrobatCompatibility to “Acrobat 5” :lol:

Best regards, Alexey.