2 Replies Latest reply on Dec 2, 2009 9:54 AM by epsobolik

    How does printerList work?

    epsobolik Level 1

      I'm trying to write a javascript script that prints an Adobe Acrobat CS2 (V12.0.1) document using a specific printer.  In the process of doing that, I tried experimenting with displaying a list of available printers - the example in reference for the PrinterInfo object...

       

      var docRef = documents.add();
      var textRef = docRef.textFrames.add();
      var iCount = printerList.length;
      textRef.contents = "Checking Printers... \n";
      textRef.contents += documents.length
      for (var i = 0; i < iCount; ++i) {
          textRef.contents += printerList[i].name + "\n";
          textRef.contents += "\tPS Level = " + printerList[i].printerInf.postScriptLevel + "\n";
          textRef.contents += "\tDevice resolution = " + printerList[i].printerInf.deviceResolution + "\n";
          textRef.contents += "\tInRIPSeparation support = " + printerList[i].printerInf.inRIPSeparationSupport + "\n";
      }
      textRef.top = 600;
      textRef.left = 200;
      redraw();

       

      It fails on line 4:

      Error 1200: an Illustrator error occurred:

      1128353364 ('CANT')

      Line: 4

      -> var iCount = printerList.length;

       

      I've had luck with other collections (see the documents.length above).  Is there something I'm missing?  Is the object name incorrect?  Is it possible to have 0 printers and therefore an empty collection?

       

      The code to print using a specific printer is:

      var printerOpts = new ActiveXObject("Illustrator.PrintOptions");
      printerOpts.printerName = "AutoCDLabels";
      doc.print(printerOpts);

       

      I'm doing this from a stand-alone javascript.  This gives an error on the doc.print line:

      Error:  an Illustrator error occurred: 1128353364('CANT')

      Code:  8001FFFF

       

      Any ideas?

       

      Phil