0

感谢这里所有乐于助人的人,我已经为 InDesign CS6 学习了大量的脚本!现在,为文档设置 printPreferences 是个问题。这是我的代码:

    with(document.printPreferences) {
        activePrinterPreset = outputPreset;
        pageRange = outputRange;
        for (var j = 0; j < allInks.length; j++) {
            document.inks.item(allInks[j]).printInk = false;
        }
        for (var k = 0; k < printInks.length; k++) {
            if (printInks[k].toString() === "Black") {
                $.writeln("Found Black!");
                printBlack = true;
                $.writeln("Set Black!");
            } else {
                document.inks.item(printInks[k]).printInk = true;
            }
        }
        if (offsetJob) {
            // If it's an offset job, we might need to change page sizes.
            if (productType === "HI-N13W") {
                paperSize = PaperSizes.custom;
                paperHeight = 12.5;
                paperWidth = 8.5;
            } else if (productType.subString(3,5) === "PC") {
                paperSize = PaperSizes.custom;
                paperHeight = 8;
                paperWidth = 12.5;
            } else if (couldBeBothJobs.toString().indexOf(productType.subString(3,5)) > -1) {
                paperSize = "US Letter";
            } else {
                paperSize = PaperSizes.custom;
                paperHeight = 8;
                paperWidth = 25;
            }
        }
    }

在第二个for循环中,您会看到我首先关闭了文档中的所有墨水进行打印。然后我只打开printInks数组中的那些。但是,如果数组中存在单词“Black”,则它没有 Ink,因此,我想设置内置的 printPreference“printBlack”。(这补充了其他三个 - printCyan、printMagenta 和 printYellow。)

根据InDesign CS6 Object Model Reference ,它应该是一个布尔值。但是,每当脚本到达该点时,它就会停止。将一小段代码粘贴到一个新文档中,这样我就可以看到错误消息,让我得到这个:

    The property is not applicable in the current state.

这是什么意思?更重要的是,我该如何解决?我知道在设置此属性之前必须关闭陷印,但我确定它已关闭。

4

1 回答 1

0

Adob​​e 社区论坛上提出这个问题后,有人告诉我,某些打印首选项不能直接在文档上设置,而是必须在打印预设上设置,然后将其设置为活动打印预设. 因此,我只是重新构建了我需要的预设并将其分配给一个新的临时预设。结果如下:

    try {
        tempPreset.name;
    }
    catch(eNoSuchPreset) {
        tempPreset = app.printerPresets.add({name:"tempPreset"});
    }

    // Let's turn off all of the spot colors before everything else.
    for (var j = 0; j < allInks.length; j++) {
        document.inks.item(allInks[j]).printInk = false;
    }

        with(document.printPreferences) {
            tempPreset.printer = Printer.POSTSCRIPT_FILE;
            tempPreset.ppd = "OYO Imagesetter";
            tempPreset.pagePosition = PagePositions.CENTERED;
            tempPreset.paperSize = PaperSizes.CUSTOM;
            tempPreset.paperHeight = "12.5 in";
            tempPreset.paperWidth = "6.5 in";
            tempPreset.colorOutput = ColorOutputModes.SEPARATIONS;
            tempPreset.trapping = Trapping.OFF;
            tempPreset.screening = "60 lpi / 600 dpi";
            tempPreset.sendImageData = ImageDataTypes.OPTIMIZED_SUBSAMPLING;
            pageRange = outputRange;
            // Now let's turn off all of the CMYK colors.
            tempPreset.printCyan = false;
            tempPreset.printMagenta = false;
            tempPreset.printYellow = false;
            tempPreset.printBlack = false;
            // Then we turn back on BLACK if it exists.
            for (var k = 0; k < printInks.length; k++) {
                if (printInks[k] === "Black") {
                    tempPreset.printBlack = true;
                } else {
                    document.inks.item(printInks[k]).printInk = true;
                }
            }
            // If this is a four-color process job, then turn back on all of the process colors.
            if (processJob) {
                tempPreset.printCyan = true;
                tempPreset.printMagenta = true;
                tempPreset.printYellow = true;
                tempPreset.printBlack = true;
            }
            // That concludes OYO seps.
        }
        var mydpp = document.printPreferences;
        mydpp.activePrinterPreset = "tempPreset";

这让我完成了这个脚本的 99%。耶!!

于 2013-06-18T17:52:22.897 回答