有没有一种方法可以关闭警告对话框,将.ai文件导出为.psd文件?

时间:2019-04-01 15:00:38

标签: javascript adobe-illustrator

我的javascript函数应该将.ai文件导出为psd文件,没有错误对话框,但代码未执行。

function exportFiletoPSD (dest) {
  if ( app.documents.length > 0 ) {
    var dest = Folder.selectDialog();
    var exportOptions = new ExportOptionsPhotoshop();
    var type = ExportType.PHOTOSHOP;
    var fileSpec = new File(dest);
    exportOptions.resolution = 300;
    exportOptions.warnings = false;
    app.activeDocument.exportFile( fileSpec, type, exportOptions );
  }
}

1 个答案:

答案 0 :(得分:0)

对于简单的情况,它是这样工作的:

function exportFiletoPSD (dest) {
  if ( app.documents.length > 0 ) {
    // var dest = Folder.selectDialog(); // <-- it doesn't need if you provided 'dest' already
    var exportOptions = new ExportOptionsPhotoshop();
    var type = ExportType.PHOTOSHOP;
    var fileSpec = new File(dest);
    exportOptions.resolution = 300;
    exportOptions.warnings = false;
    app.activeDocument.exportFile( fileSpec, type, exportOptions );
  }
}

exportFiletoPSD('d:/temp/my_file.psd') // it saves current opened file in my_file.psd

还有其他功能,取决于您的目标。