寻找在 InDesign 中批量导出 pdf:s 的更快方法

Looking for a faster way to batch export pdf:s in InDesign

我正在使用这个脚本(如下)从多个 indesign 文件中批量导出 pdf:s 以完成我每周执行的任务。文件名总是相同的,我使用 8-10 个不同的 indd 文件来创建 12-15 个不同的 pdf:s.

脚本是这样设置的:

//Sets variables for print and web presets
var myPDFExportPreset = app.pdfExportPresets.item("my-present-for-print-pdf");
var myPDFExportPreset2 = app.pdfExportPresets.item("my-preset-for-web-pdf");

//sample of one pdf exported first with print, then web pdf preset as two different files

var firstFileIntoPdfs = function(){

var openDocument= app.open(File("MYFILEPATH/firstfile.indd"));

    openDocument.exportFile(
        ExportFormat.pdfType,
        File("MYFILEPATH/print-pdfs/firstfile-print.pdf"),
        false, 
        myPDFExportPreset
    );

    openDocument.exportFile(
        ExportFormat.pdfType,
        File("MYFILEPATH/web-pdfs/firstfile-web.pdf"),
        false, 
        myPDFExportPreset2
    );
};

我正在将所有像上面那样的导出定义为命名函数,有些只使用一种预设,有些像上面那样使用两种。我在文件末尾调用所有这些函数

firstFileIntoPdfs();
secondFileIntoPdfs();
thirdFileIntoPdfs();
fourthFileIntoPdfs();

等等... ¨

然而,该脚本相当慢,10 个文件,每个文件分为 1 或 2 个 pdf,就像上面的功能一样,可能需要 10 分钟。我不认为这是一个 CPU 问题,我注意到脚本似乎正在等待 "firstFileIntoPdfs()" 中的文件被创建,这个过程需要几分钟,然后才能继续执行下一个函数。然后再等...

选择文件 -> 手动导出您可以设置要导出的新文件,而以前的文件仍在处理 pdf 文件,对我来说这似乎比这个脚本的工作方式更快。当然,手动点击容易出错且乏味。

有没有比我上面做的更好的方法来编写这个批量导出脚本,这将使所有函数执行,而以前函数的 pdf 仍在系统中处理? 我想将它们保留为单独的函数,以便在只需要某些特定的 pdf:s 时能够注释掉一些。 (除非全部导出的过程变得几乎与仅导出 1 个 pdf 一样快)。

希望我的问题有道理!

有可用的异步方法,将 exportFile 替换为 asynchrousExportFile:

var openDocument= app.open(File("MYFILEPATH/firstfile.indd"));
openDocument.asynchronousExportFile(
    ExportFormat.pdfType,
    File("MYFILEPATH/print-pdfs/firstfile-print.pdf"),
    false, 
    myPDFExportPreset
);

使用后台任务