Skip navigation
PerryPDP
Currently Being Moderated

Illustrator javascript Save as PDF - issue defining enumerated values as a variable

May 17, 2013 9:13 AM

Tags: #illustrator #save #pdf #javascript #as

Hi,


I am trying to figure out how I can use a variable as the target for a Save as PDF option in Illustrator javascript. the variables work fine where there is no enumerated value for the property i.e. opts.generateThumbnails but I can figure out how to get it working opts.compatibility or other properties with enumerated values using a variable as the definition.


The code snippet example below will always give an 'Enumerated Value expected' error when run for the opts.colorCompression option even though the string is correct.

If I define the opts as opts.colCompression = compressionQuality.AUTOMATICJPEGHIGH then everythings works


Does anyone know of how I can define the compressionQuality.AUTOMATICJPEGHIGH as a variable the will work


Tks


Code snippet


opts = new PDFSaveOptions();

opts.compatibility = PDFCompatibility.ACROBAT5;

opts.generateThumbnails = thumbnailValue;

opts.preserveEditability = editingValue

opts.optimization = optimizationValue;

opts.colorCompression = colCompressionDefault;


// default value is defined at the start of the script as:-

// var colCompressionDefault = 'compressionQuality.AUTOMATICJPEGMAXIMUM';


alert("Options Color Compression = " + opts.colorCompression);


for (x = 0; x < doc.artboards.length; x++ )

{


doc.artboards.setActiveArtboardIndex( x );

var artboardName = doc.artboards[x].name;


if ( ( artboardName.match( /^Printed/i ) ))

{

opts.artboardRange = x+1;

expFile = File( destFolder + '/'+ nameString + '-' + doc.artboards[x].name + '.pdf' );

doc.saveAs ( expFile, opts );      //This is the lien that fails

}

}


//close the open document

sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

 
Replies
  • Currently Being Moderated
    May 17, 2013 9:30 AM   in reply to PerryPDP

    you're defining your compression variable as String, it needs to be an Enumeration

     

    change this

    var colCompressionDefault = 'compressionQuality.AUTOMATICJPEGMAXIMUM';
    

     

    to this

    var colCompressionDefault = CompressionQuality.AUTOMATICJPEG2000MAXIMUM;
    
     
    |
    Mark as:
  • Currently Being Moderated
    May 17, 2013 12:44 PM   in reply to PerryPDP

    if you have an information on how I should define...

     

    I do, I showed you how in my previous post, Javascript is case sensitive,

     

    this does not exist

    compressionQuality.AUTOMATICJPEGMAXIMUM
    

     

    this does

     

    CompressionQuality.AUTOMATICJPEG2000MAXIMUM
    
     
    |
    Mark as:
  • Currently Being Moderated
    May 17, 2013 2:35 PM   in reply to PerryPDP

    don't worry , that's how it is at the beginning

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points