Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Another frustrating printing question

Contributor ,
Oct 31, 2015 Oct 31, 2015

So one thing I just realized is that your print options do not go through until you use the print() method. This is very frustrating because I do not know what kind of Inks are being printed for the entire screen(s). When I open a document, it automatically defaults to the 8.5 by 11 media size, so if there is a color that is not supposed to be there and it is at the top of the screen, I am not going to know because the ink list is only for the 8.5 by 11 area not the entire 17 by 20. 

Untitled-1.jpg

You can see here, the left is what I am getting for my ink list, so spot black will show up as disabled for my script. The right is how it should be, but unfortunately those settings don't apply until after the print() method happens. So I am kind of in the dark on what all is being printed. ugh. If anyone has ran into this issue and found a good workaround please let me know. Thanks everyone and have a Happy Halloween!

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Contributor ,
Oct 31, 2015 Oct 31, 2015

Here's my code in case this gives a better understanding of my problem. In line 22 I thought I would be getting the correct print area from that point on because the artboard is always the correct size, but I am not. I made sure to define the inklist afterwards as well. I have alert messages to test which colors it can sense and I have learned that colors outside of the 8.5 by 11 area and within the correct 17 20 print area are not enabled on the ink list. 

/*

    IDEAS:

  

    IF INK LIST CANT BE FIXED, COMPARE LIST BEFORE AND AFTER PRINTED. IF DIFFERENT, ALERT THE USER.

  

    */

app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;

printPostScript();

function printPostScript() {

 

    app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

    

    var docPath, docRef, inFolder, opts, psPath;

    

  jobOpts = new PrintJobOptions();

  //Should work right? Not till it prints, doh!!!!

  jobOpts.printArea = PrintingBounds.ARTBOARDBOUNDS;

  opts = new PrintOptions();

  //opts.printPreset = 'Print Preset 1';

    

  opts.jobOptions =  jobOpts;

  opts.PPDName = 'AdobePdf';

  

  opts.printerName= 'Adobe PostScript File';

  sepOpts = new PrintColorSeparationOptions();

  sepOpts.colorSeparationMode = PrintColorSeparationMode.HOSTBASEDSEPARATION;

  opts.colorSeparationOptions = sepOpts;

   

        

var cmyk = false;

docRef = app.activeDocument;

//hoping the doc would be reading 17 by 20 print area at this point....not successful yet.

sepOpts.inkList = docRef.inkList;

        

      

for (i = 0; i < 4; i ++) {

    

            if (sepOpts.inkList.inkInfo.printingStatus == InkPrintStatus.ENABLEINK) {

              

        cmyk = true;

        

          }

    

    

      }

if (cmyk == false) {

  

  

var numbers = ' ';

var colorsOnScreen = [];

var x = 0;

for (j= docRef.groupItems.length-1; j > -1; j--) {

    if (docRef.groupItems.name == 'numGroup' && Math.round(docRef.groupItems.left) == 639 && Math.round(docRef.groupItems.top) ==  -21) {

  

    var numGroup = docRef.groupItems;

  

        for (k = numGroup.textFrames.length - 1; k > -1; k --) {

              

                if (numGroup.textFrames.textRange.characterAttributes.fillColor == '[SpotColor]'){

  

                //put numbers at end of file name

              numbers = numbers + ' ' + String(numGroup.textFrames.contents)

            

              //cross reference this with enabled colors, disable colors that don't match....background color for one of them

              colorsOnScreen = numGroup.textFrames.textRange.characterAttributes.fillColor.spot.name;

            

              x++

                          

                    }        

          

            }

    }

}

  

var docName = docRef.name.replace( /.ai$/, '' );

psPath = docName.replace(/\./g , "_" );

// on garnment color and number screens

// file name preview

//gets rid of content between paranthesis

var updatedPath = psPath.replace(/ *\([^)]*\) */g, "");

var myWindow = new Window ("dialog", "Post Script Generator");

myWindow.orientation = "column";

myWindow.alignChildren = "left";

var colorGroup = myWindow.add("group");

colorGroup.orientation = "column";

colorGroup.alignChildren = "left";

var colorPanels= [];

u=0;

var inkEn = [];

c=0;

var gc = 'white';

for (t = 4; t < sepOpts.inkList.length; t ++) {

    alert(sepOpts.inkList.name)

    alert(sepOpts.inkList.inkInfo.printingStatus)

    

            if (sepOpts.inkList.inkInfo.printingStatus == InkPrintStatus.ENABLEINK) {

              

                inkEn = sepOpts.inkList;

                c++;

      colorPanels = colorGroup.add("group");

      colorPanels.alignChildren = "left";

  

    colorPanels.add ("statictext", [0, 0, 100, 12], sepOpts.inkList.name);

    var yes = colorPanels.add("checkbox", undefined, 'Print');

    colorPanels.add("checkbox", undefined, 'Halftone');

  

    for (l=0; l < colorsOnScreen.length; l++) {

            if (sepOpts.inkList.name == colorsOnScreen) {

            yes.value = true;

        }

 

        }

        u++;

      if (yes.value != true) {

    

      // the garment color is the one we are not outputting. In rare instances of not outputting more than one color, it's a guess.

      gc = sepOpts.inkList.name;

          }

      

      }

}

var colorCheck = gc.indexOf ('PMS');

var spotCheck = gc.substr (0, 4);

if (colorCheck > 1) {

  

    gc = gc.substr(0,colorCheck - 1);

  

    }

else if (spotCheck == 'SPOT') {

  

    gc = gc.substr(5,gc.length);

    }

var nameGroup = myWindow.add("group");

nameGroup.orientation = "row";

nameGroup.add ("statictext", undefined, "File:");

// put file name preview here

var myText = nameGroup.add ("edittext", undefined, updatedPath);

myText.characters = 80;

myText.active = false;

nameGroup.add ("statictext", undefined, "Garment:");

var myText2 = nameGroup.add ("edittext", undefined, gc);

myText2.characters = 20;

myText2.active = true;

var okButton = nameGroup.add ("button", undefined, "OK");

nameGroup.add ("button", undefined, "Cancel");

if (myWindow.show () == 1) {

for(v=0; v < colorPanels.length; v ++) {

  

      

        if (colorPanels.children[1].value == false) {

            //turn off print        

                for (m = 0; m < inkEn.length; m ++) {

                

                  if (inkEn.name == colorPanels.children[0].text) {

                    

                      inkEn.inkInfo.printingStatus = InkPrintStatus.DISABLEINK;

                      

                        }

                  

                    }

       

            }

        else {

            //check half tones

            if (colorPanels.children[2].value == true) {

              

                for (m = 0; m < inkEn.length; m ++) {

                

                        if (inkEn.name == colorPanels.children[0].text) {

                

                      inkEn.inkInfo.angle = 30;

                      inkEn.inkInfo.frequency = 42;

                

                        }

                  

                        }

              

                }

          

            }

  

    };

  // add garment color to the end of file name, delete everything after parenthesis, turn periods to hyphens or underscore

    

        docPath = decodeURI( '//fileserver/SpoolFolder/' + myText.text + ' on ' + myText2.text + ' ' + numbers + '.ps' );

      

        docPath2 = decodeURI( '//fileserver/ImageFolder/' + myText.text + ' on ' + myText2.text + ' ' + numbers + '.ps' );

      

        // inkEn

 

        jobOpts.file = File( docPath );

        app.activeDocument.print( opts );

      

          jobOpts.file = File( docPath2 );

        app.activeDocument.print( opts );

    }

  

  }

else {

  

    alert('CMYK COLOR DETECTED','Crap');

  

    }

};

So yea, for this to work correctly I would need to have the right print area before it prints. Through UI you can select a print preset and hit 'done' instead of print, been trying to find a way to do that through script, have not yet. Send Keys is always an option but that leaves room for error.

Tried looking for a way that Illustrator always has a print preset active no matter what file you open, haven't found that either.

An alternative would be to compare the inklist before and after print has taken place and then alert the user if it's different, but that would still create some work by having to go and delete files, and I want as little work as possible lol.

Guess I could randomly print something at the beginning and then define the inklist but that would be poopy having to print extra files.

So close yet so far. I'm done for the day, take care everyone!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 01, 2015 Nov 01, 2015

this worked fine for me.

I'm not sure if I am missing something but all spot colors worked fine.

unless I have not understood the issue.

if I am correct I would again suggest ignoring what you see in illustrator, and focus on what is output.

the ps file can be opened in a text area and all the plate info is near the bottom of the file.

check there to see if it has all the spot colors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2015 Nov 02, 2015

Thanks for looking at it. I know that all the colors are going to be printed, the problem is trying to catch colors that aren't supposed to be there before it prints. By the time artwork gets to me it is supposed to be converted entirely to spot colors that are specified. Unfortunately though, people make a lot of mistakes and there will be extra spot colors or even worse, cmyk colors still in the art. So I need to know what is all going to be printed before hand so I know if I need to fix something and I don't have extra screens in the postscript file. 


Whenever you open a new document in Illustrator, it automatically has it set up for a 8.5 11 print area. Even though I tell it to use the artboard as the printing bounds at the beginning of the script, that doesn't take into effect until it actually prints. So anything outside of the 8.5 11 print area will not get detected.


Untitled-2.jpg


The red dotted line is the 8.5 11 area it is looking at. I put a random cmyk square at the top right to test it, and it went through without being detected.


I added a dud print (a print I just save to my desktop that serves no purpose) at the beginning of the script with the correct print area before the cmyk detection, and then it was detected. So I guess I could use that as a solution if I have to, it just slows down the script a little bit.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 02, 2015 Nov 02, 2015

Hey, sorry if I am ignorant here, but if you are merely looking to see which colors are printed/not printed using the artboards, can you not simply use the inkList of the document without venturing in the print functions?
I thought that the default document inkList provides an accurate picture of the printable colors using any non-pasteboard area.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2015 Nov 02, 2015

Thanks for looking at this, it still goes by the print area for me even without the print options.

docRef = app.activeDocument;

var inks = docRef.inkList;

for (i=0; i < inks.length; i++) {

    alert(inks.name + inks.inkInfo.printingStatus)

    }

Anything outside of the red dash area is showing up as disabled. I'm using cs6 maybe it goes by the artboard in other versions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 02, 2015 Nov 02, 2015

Well, no, maybe it is just like the TIFF resolution issue where the script will use the last user-set resolution in the TIFF exports.. I actually have had this phenomenon happen to me only twice when I was in the position of using my own script to check my own inkLists for this very purpose, and I attributed it to an unknown and yet too rare of an internal error.

Ha, I guess it is your solution which I also was going to suggest before reading your post completely that I would use.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 02, 2015 Nov 02, 2015

Yea haha. It doesn't slow me down too much at least since post scripts are so small anyway. Still a lot quicker than not using a script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 03, 2015 Nov 03, 2015

this has me a bit stumped.

I can't seem to recreate the problem or I don't understand the problem.

I think if you could supply an example file and a simple step by step process of what you want to achieve I may be able to wrap my brain around it, but no promise.

as far as I know a CMYK document, even brand new with nothing on it and all swatches removed will still have 4 plates in inkList for CMYK.

Is this close?:

find all colors used within a certain print area and check against a list of expected colors, alert of any items that deviate from this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 04, 2015 Nov 04, 2015

example file.ai - Google Drive

Sure thing,

The problem is knowing which inks are enabled so you know everything you are going to print beforehand.

Above is an example file, I am not sure how to upload files on here so I just used google drive. If you run this script below with that file, it will show you the enabled inks before and after it prints. You can see, as long as the default print settings dont change on your computer, it goes by that 8.5 11 print area even though I set the print bounds as artboard bounds before in the script. It will not change until after something prints.

The alert messages should first have RED and BLACK (the colors within that area), and then after it prints, the print area will change causing the C M Y K colors that were outside of the area to be shown as well as the RED and BLACK.

var jobOpts = new PrintJobOptions();

 

   jobOpts.printArea = PrintingBounds.ARTBOARDBOUNDS;

  

   var opts = new PrintOptions();

   //opts.printPreset = 'Print Preset 1'; 

     

    opts.jobOptions =  jobOpts; 

  

   opts.PPDName = 'AdobePdf';

   

   opts.printerName= 'Adobe PostScript File';

  

   var sepOpts = new PrintColorSeparationOptions();

  

   sepOpts.colorSeparationMode = PrintColorSeparationMode.HOSTBASEDSEPARATION;

  

   opts.colorSeparationOptions = sepOpts;

  

  

   for (i=0; i < docRef.inkList.length; i++)   {

      

       if (docRef.inkList.inkInfo.printingStatus == InkPrintStatus.ENABLEINK) {

          

           // RED BLACK

           alert(docRef.inkList.name)

          

           }

      

       }

  

   docPath3 = decodeURI( '~/Desktop/' + 'dud' + '.ps' ); 

   

         jobOpts.file = File( docPath3 ); 

        app.activeDocument.print( opts );    

       

       

       

         for (i=0; i < docRef.inkList.length; i++)   {

      

       if (docRef.inkList.inkInfo.printingStatus == InkPrintStatus.ENABLEINK) {

          

           //C M Y K RED BLACK

           alert(docRef.inkList.name)

          

           }

      

       }

The way I am doing it now is just like in the script, I will just print an extra file once to the desktop before hand to get the correct print area, and then later in the script print the actual files that get used. I was just wondering if there was a better way than having to print that extra file but if not it is not the end of the world, it prints it off pretty fast so it doesn't lag down the script that much.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 05, 2015 Nov 05, 2015
LATEST

Ok, I get what your saying now.

not that the plate exists or not, but if it is Enabled or not.

the only thing I can think of is if you do a:

  try{

       app.activeDocument.print( opts );    

  }catch(e){}

and hit cancel then print options get saved and inks will still get enabled.

but this requires user interaction,

it could be done using send keys by executing a VBscript or applescript.

issue there is it is prob just as much lag as printing. but may not be if the file is complex.

would not be hard to knock up the VBscript (applescript is not my domain.) but even if it is a fraction faster, it is prob less reliable then just printing the dud file.

if I think of anything else I will let you know.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines