4 Replies Latest reply on Feb 14, 2016 4:55 PM by levonkps

    Listing used swatches on artboard

    levonkps Level 1

      I am trying to create a list of the swatches that are used on a single artboard in a document that might contain more than one artboard. The document uses sot colours. My script checks if it uses CMYK, and stops with an alert if it does. I have been able to get a list of the swatches in the whole document by looping the sepInkList and checking the inkInfo.printingStatus property. However, I am not able to do that for a single artboard. In the print dialog, if I select to print a single artboard, Illustrator is smart enough to select only the colours used on that artboard. However, I am not able to simulate that through scripting.

      This is the script that I used:

        var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];
        var sepOptions = new PrintColorSeparationOptions();
        sepOptions.colorSeparationMode = PrintColorSeparationMode.HOSTBASEDSEPARATION;
        var printJobOptions= new PrintJobOptions();
        var printOptions = new PrintOptions();
        var activeArtboardNumber=doc.artboards.getActiveArtboardIndex();
        printJobOptions.printAllArtboards = false;
        var printPage=activeArtboardNumber + 1;
        printJobOptions.artboardRange = printPage.toString();
        printOptions.colorSeparationOptions = sepOptions;
        printOptions.jobOptions = printJobOptions;
        var iLength = sepInkList.length;
        for(var i=0; i<iLength; i++) {
             if (sepInkList[i].inkInfo.printingStatus == InkPrintStatus.ENABLEINK) {
                  var textRef = doc.textFrames.add();
                  textColor = doc.swatches.getByName(sepInkList[i].name).color;
                  textRef.contents = sepInkList[i].name;
                  textRef.textRange.size = 12;
                  textRef.textRange.fillColor = textColor;
             }
        }
      
      

       

      However this still prints all the colours in the document not just the artboard.

       

      Is there anyway to make illustrator enable only the inks in the active artboard?

        • 1. Re: Listing used swatches on artboard
          CarlosCanto Adobe Community Professional & MVP

          hide all objects, except the ones in the active artboard, hidden objects won't print.

          • 2. Re: Listing used swatches on artboard
            levonkps Level 1

            I thought of that and tried this:

              var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()]; 
              var sepOptions = new PrintColorSeparationOptions(); 
              sepOptions.colorSeparationMode = PrintColorSeparationMode.HOSTBASEDSEPARATION; 
                // Hide all objects not on current Artboard
                doc.selectObjectsOnActiveArtboard();
                for(var i=0; i<doc.pageItems.length; i++){
                    if(doc.pageItems[i].selected != true){
                        doc.pageItems[i].hidden=true;
                     }
                }
            var printJobOptions= new PrintJobOptions(); 
              var printOptions = new PrintOptions(); 
              var activeArtboardNumber=doc.artboards.getActiveArtboardIndex(); 
              printJobOptions.printAllArtboards = false; 
              var printPage=activeArtboardNumber + 1; 
              printJobOptions.artboardRange = printPage.toString(); 
              printOptions.colorSeparationOptions = sepOptions; 
              printOptions.jobOptions = printJobOptions; 
              var iLength = sepInkList.length; 
              for(var i=0; i<iLength; i++) { 
                   if (sepInkList[i].inkInfo.printingStatus == InkPrintStatus.ENABLEINK) { 
                        var textRef = doc.textFrames.add(); 
                        textColor = doc.swatches.getByName(sepInkList[i].name).color; 
                        textRef.contents = sepInkList[i].name; 
                        textRef.textRange.size = 12; 
                        textRef.textRange.fillColor = textColor; 
                   } 
              } 
            

            It still includes all colours in the document even when they are hidden

            • 3. Re: Listing used swatches on artboard
              levonkps Level 1

              Found the problem.

               

              I need to hide before I start my setup. I moved the hide commands to the top of the script and it worked.