Skip to main content
Participant
February 21, 2018
Answered

Exporting TIFF via script not working

  • February 21, 2018
  • 1 reply
  • 799 views

Hey,

I need to export a TIFF (with the respective settings like resolution, lzwCompression etc. I looked at the Java Script scripting guide and found an example script on Page 63. However the script does not work and only leads to an "Unknown error" message in illustrator.

Can anyone help me? Even just opening the "Export as" function would be helpful!

Thanks and best regards

    This topic has been closed for replies.
    Correct answer Doug A Roberts

    you need to call the function. also, yeah, use this to bring up a folder select dialog:

    var dest = Folder.selectDialog( 'Please choose a folder' );

    function exportFileToPSD (dest) {

    if ( app.documents.length > 0 ) {

    var exportOptions = new ExportOptionsTIFF();

    var type = ExportType.TIFF;

    var fileSpec = new File(dest);

    exportOptions.resolution = 150;

    exportOptions.byteOrder = TIFFByteOrder.IBMPC;

    exportOptions.IZWCompression = false;

    app.activeDocument.exportFile( fileSpec, type, exportOptions );

    }

    }

    exportFileToPSD (dest)

    1 reply

    Doug A Roberts
    Community Expert
    Community Expert
    February 21, 2018

    this script?

    function exportFileToPSD (dest) {

    if ( app.documents.length > 0 ) {

    var exportOptions = new ExportOptionsTIFF();

    var type = ExportType.TIFF;

    var fileSpec = new File(dest);

    exportOptions.resolution = 150;

    exportOptions.byteOrder = TIFFByteOrder.IBMPC;

    exportOptions.IZWCompression = false;

    app.activeDocument.exportFile( fileSpec, type, exportOptions );

    }

    }

    seems to work fine for me. did you replace 'dest' on line 5 with your file path and name? and then actually run the function?

    RPT89Author
    Participant
    February 21, 2018

    Hey, thanks for your response - yes, I mean exactly that script. I now defined dest as a variable containing the location but nothing happens when I run the script.

    var dest = "C:/Users/Administrator/Desktop/EXPORT";

    function exportFileToPSD (dest) {

    if ( app.documents.length > 0 ) {

    var exportOptions = new ExportOptionsTIFF();

    var type = ExportType.TIFF;

    var fileSpec = new File(dest);

    exportOptions.resolution = 150;

    exportOptions.byteOrder = TIFFByteOrder.IBMPC;

    exportOptions.IZWCompression = false;

    app.activeDocument.exportFile( fileSpec, type, exportOptions );

    }

    }

    What could be the reason? Also: would it be possible to let the user decide where to store the file?

    Doug A Roberts
    Community Expert
    Doug A RobertsCommunity ExpertCorrect answer
    Community Expert
    February 21, 2018

    you need to call the function. also, yeah, use this to bring up a folder select dialog:

    var dest = Folder.selectDialog( 'Please choose a folder' );

    function exportFileToPSD (dest) {

    if ( app.documents.length > 0 ) {

    var exportOptions = new ExportOptionsTIFF();

    var type = ExportType.TIFF;

    var fileSpec = new File(dest);

    exportOptions.resolution = 150;

    exportOptions.byteOrder = TIFFByteOrder.IBMPC;

    exportOptions.IZWCompression = false;

    app.activeDocument.exportFile( fileSpec, type, exportOptions );

    }

    }

    exportFileToPSD (dest)