2 Replies Latest reply on Jun 18, 2013 10:47 AM by Sturm359

    Cannot set the printBlack printPreference in InDesign

    Sturm359 Level 1

      I am finding myself running into a brick wall and it is upsetting me greatly. It's a problem with setting the printPreferences for a document. Here is the code I have:

       

          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;

                  }

              }

          }

       

      In the first FOR loop, you'll see that I have first turned off ALL of the inks in the document for printing. I then only turn on the ones in the "printInks" array in the second FOR loop. If, however, the word "Black" exists in the array, there isn't an Ink for it, so instead, I want to set the built-in printPreference "printBlack". (Which complements the other three—printCyan, printMagenta, and printYellow.)

       

       

      It's just supposed to be a boolean value, according to the InDesign CS6 Object Model Reference. However, whenever the script gets to that point, it halts. Pasting just that small bit of code to a fresh document, just so I can see the error message, gets me this:

       

          The property is not applicable in the current state.

       

      Huh? What does this mean? And more importantly, how can I fix it? I know that trapping has to be off before this property can be set, but I've definitely made sure that it is off. Can anyone please help?

        • 1. Re: Cannot set the printBlack printPreference in InDesign
          Jump_Over Level 5

          Hi,

           

          there is also ColorOutputModes.SEPARATIONS needed and... I am not sure if more...

          Maybe better way is to set properties of printer outputPreset instead of doc.printPreferences which is mixed with preset..., or create some "tempPreset" just for THIS event.

           

          I mean:

          outputPreset.printBlack = true;

          outputPreset.paperSize = "US Letter";

          and so on...

           

          Jarek

          • 2. Re: Cannot set the printBlack printPreference in InDesign
            Sturm359 Level 1

            Yes, that took care of it.  Instead of invoking an existing Print Preset, I just created a new, temporary one and gave it all of the properties of the existing one.  Thus, the result is:

             

                        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";

             

            It could still use some work, but otherwise this is quite functional and works great!  Thanks, Jump_Over!