В дистрибутиве Esko DeskPack 20.0.1, есть пример скрипта для экспорта нормализованного PDF (EskoAIExportEskoPDF.jsx). Скорее всего, это кусок кода, который нужно адаптировать под свою задачу. Помогите разобраться как заставить работать скрипт. Платформа Mac, Adobe Illustrator 2020, пути проверил, прописаны правильно.
Код:
/**
* Sample scripts are provided as-is with no warranty of fitness for a particular purpose.
* These scripts are solely intended to demonstrate techniques for accomplishing common tasks.
* Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.
*
* It is up to the user to verify that his intended use of the offered automation functionality is compliant with any third party license agreement and/or other restrictions applicable to any non-Esko products.
*/
// Target: Illustrator
// Esko sample JSX for export of Esko PDF (Normalized or PDF+, based on the document mode)
function main(inputs, outputFolder, params)
{
try
{
// First set the search path that contains the PDF Export plug-in
var externalSearchFolder = ExternalObject.searchFolder;
ExternalObject.searchFolders="/Applications/Adobe Illustrator 2020/Plug-ins.localized/Esko/Data Exchange/PDF Export;" + externalSearchFolder;
if (!ExternalObject.search("lib:PDFExport_MAI24r.aip"))
throw "The PDF Export plug-in could not be found.";
var dw = new ExternalObject("lib:PDFExport_MAI24r.aip");
// Create EskoPDFExport
var scripter = new EskoPDFExport();
// Set export parameters
scripter.borderMode = 1; // kBordersModeArtworkBoundingBox = 1,
// kBordersModeCurrentArtboard = 2,
// kBordersModeTrimBox = 3
scripter.fitMediaBoxToArtwork = false;
scripter.outlineText = false;
scripter.includeHiddenObjectsAndLayers = false;
scripter.includeNotes = true;
scripter.embedImages = true;
scripter.addPreview = false;
scripter.copyImages = false;
scripter.copyImagesNotOnServers = false;
scripter.expandPatterns = false;
scripter.contourizeBitmaps = false;
scripter.blendResolution = 0;
scripter.copyStructuralDesignFilesNotOnServer = false;
for (i = 0; i < inputs.length; i++)
{
var fileRef = new File(inputs[i]);
var docoutp= outputFolder + "/" + fileNameWithoutExtension(fileRef) + ".pdf";
scripter.outputPath = docoutp;
$.writeln("Exporting " + docoutp);
var docRef = app.open(fileRef);
scripter.exportPDF();
//check if export operation is successful
var ErrorCode = scripter.errorCode;
var ErrorMessage = scripter.errorMessage;
var AllMessages = scripter.formattedExportMessage;
if (ErrorCode == 0)
$.writeln("Export success, " + inputs[i] + "\n" + "Messages:\n"+ AllMessages);
else
$.writeln("Export failed, " + inputs[i] + "\n" + "Error Code: " + ErrorCode + " Error Message:" + ErrorMessage);
docRef.close();
}
}
catch (e)
{
// Log the error info and return Error
if (e.substring)
$.writeln("Error: substring " + e);
else
$.writeln("Error: " + (e.number & 0xFFFF) + ", " + e.description);
return "Error";
}
return "OK";
}
function fileNameWithoutExtension(fileref)
{
// Get the file name
var filename = fileref.name;
// Locate the position of the last dot
var lastdotidx = filename.lastIndexOf(".") ;
if (lastdotidx > 0)
{
// Return the file name without extension
return filename.substr(0, lastdotidx);
}
else
{
// The file name has no extension or starts with a dot
return filename;
}
}
Вложения
Последнее редактирование: