这个对你来说应该很简单Javascript / Extendscript向导。我想使用打印预设打印文档,同时还指定页面范围(以及选择预设后可能还有其他选项)。咨询InDesign CS6 JavaScript脚本编写指南,它有如此精彩的详细解释:
使用打印机预设进行打印
要使用打印机预设打印文档,请在打印命令中包含打印机预设。
哇。如此具有描述性和帮助性。嗯,有人能帮助我更好地理解这个吗?
编辑(01/21/2019)
我被问到如何能够告诉脚本我要打印哪些页面。事实证明,这并未存储在PrinterPreset
。
Document
有一个名为printPreferences
的属性,允许访问PrintPreference
对象。此对象允许开发人员通过指定pageRange
枚举或带有页面范围的字符串(使用" 1"作为第一页)来设置PageRange
。
所以,举例说明:
var document = app.activeDocument; // Presumes the document you want to print is already open.
document.printPreferences.pageRange = PageRange.ALL_PAGES; // Will print all pages in the document.
document.printPreferences.pageRange = "1-3,7,10,12-15" // Prints pages 1, 2, 3, 7, 10, 12, 13, 14, and 15.
注意:
PageRange.SELECTED_ITEMS
似乎只用于导出项目,而不是用于打印(因为PageRange
枚举用于两者 操作)。但是,我没有测试过这个。
在调用document.print()
之前,可以设置许多其他PrintPreference
属性,因此它值looking them up。
答案 0 :(得分:2)
app.print()
方法可以将PrinterPreset
对象作为其中一个参数。以下是方法参考的link以获取更多信息。
这是一个例子(未经测试):
var doc = app.activeDocument;
var file = File(doc.fullName); // Get the active document's file object
var preset = app.printerPresets[0]; // Use your printer preset object
app.print(file, null, preset);
InDesign参考或多或少地列出了app.print()
方法:
void print (from: varies[, printDialog: bool][, using: varies])
Prints the specified file(s).
Parameter Type Description
from Array of Files One or more file paths. Can accept: File or Array of Files.
File
printDialog bool Whether to invoke the print dialog (Optional)
using PrinterPreset Printer preset to use. Can accept: PrinterPresetTypes enumerator or PrinterPreset. (Optional)
PrinterPresetTypes
列出的第一个信息是方法的返回值void
,在这种情况下,这意味着它不会返回任何内容。
列出的下一个信息是方法的名称print
,后面跟着它的命名参数:from
,printDialog
和using
以及每个参数类型应该是什么是
参数也列在图表中以供进一步说明。 from
参数需要一个类型为File
的对象。因此,在上面的示例中,我通过调用它的构造函数File
来创建var file = File(doc.fullName);
对象的“实例”。然后我得到一个已存在的PrinterPreset
对象:var preset = app.printerPresets[0];
。最后,我将每个对象传递给插入null
中间变量的函数(因为它是可选的,我只是决定忽略它):app.print(file, null, preset);
。