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

Printing Specific Separations With Scripting

Community Beginner ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hi Community,

 

I'm trying to use python (via win32com) to print from Illustrator some desired separations of PDF files. Please see code below.

I do know that communication with Illustrator print options works: It indeed changes mode to HOSTBASEDSEPARATION as requested.

However, the document being sent to print using this method has all colors in it (separated to different spreads).

 

Also tried: sending inkList with only the requested separations, instead of sending all separations.

 

Am I doing something wronge? Did I forget some required steps?

 

Best regards,

Or

 

I'm Using Illustrator 2021, python 3.7.

import win32com.client as win32com

# Access the document opened in Illustrator
adobe_app = win32com.GetActiveObject("Illustrator.Application")
adobe_document = adobe_app.ActiveDocument

#Initialize required variables
print_color_management_options = win32com.Dispatch("Illustrator.PrintColorManagementOptions")
printer = win32com.Dispatch("Illustrator.Printer")
print_option = win32com.Dispatch("Illustrator.PrintOptions")
print_color_separations_options = win32com.Dispatch("Illustrator.PrintColorSeparationOptions")

# change mode to PrintColorSeparationMode.HOSTBASEDSEPARATION, according to table in section 42.88 in the documentation.
print_color_management_options.ColorSeparationMode = 1

#Set Disable to all 4 Process colors, neglect 5th Spot Color.
ink_list = adobe_document.InkList
for idx in range(len(ink_list)-1): # For all except the last
    ink_list[idx].InkInfo.PrintingStatus = 2 # According to section 42.59 in the documentation.
print_color_separations_options.InkList = ink_list

# Update options and send to print
print_option.ColorSeparationOptions = print_color_management_options
adobe_document.PrintOut(print_option)

 

TOPICS
Print and publish , Scripting , SDK

Views

377

Translate

Translate

Report

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
Community Beginner ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Not sure why I don't have access to edit my discussion above, but I did a mistake in the cited code. Here is the actual one:

import win32com.client as win32com

# Access the document opened in Illustrator
adobe_app = win32com.GetActiveObject("Illustrator.Application")
adobe_document = adobe_app.ActiveDocument

#Initialize required variables
print_color_management_options = win32com.Dispatch("Illustrator.PrintColorManagementOptions")
printer = win32com.Dispatch("Illustrator.Printer")
print_option = win32com.Dispatch("Illustrator.PrintOptions")
print_color_separation_options = win32com.Dispatch("Illustrator.PrintColorSeparationOptions")

# change mode to PrintColorSeparationMode.HOSTBASEDSEPARATION, according to table in section 42.88 in the documentation.
print_color_separation_options.ColorSeparationMode = 1

#Set Disable to all 4 Process colors, neglect 5th Spot Color.
ink_list = adobe_document.InkList
for idx in range(len(ink_list)-1): # For all except the last
    ink_list[idx].InkInfo.PrintingStatus = 2 # According to section 42.59 in the documentation.
print_color_separation_options.InkList = ink_list

# Update options and send to print
print_option.ColorSeparationOptions = print_color_separation_options
adobe_document.PrintOut(print_option)

Votes

Translate

Translate

Report

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
Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hey, here's a script that will print separations for the current file. There are tons of possible settings so I'd suggest going through the print setup manually to get everything as you want it, then scroll down in the dialog to "Summary". The summary will list every setting you have for that print job. You can even save the summary to a file for later reference. I have attached a sample summary file for example. From there, you can review the documentation linked in the code to make whatever changes you need.

 

Hopefully, this helps...✌️

 

var doc = app.activeDocument;

// set print options
// https://ai-scripting.docsforadobe.dev/jsobjref/PrintOptions.html?highlight=printer
var options = new PrintOptions();
options.printerName = "Adobe PostScript File";
options.PPDName = "Roland VersaWorks";

// define vars for specific print settings
var customPaper = new PrintPaperOptions();
var coordinateOptions = new PrintCoordinateOptions();
var sepOptions = new PrintColorSeparationOptions();

options.paperOptions = customPaper;
options.coordinateOptions = coordinateOptions;
options.colorSeparationOptions = sepOptions;

// set paper size
// https://ai-scripting.docsforadobe.dev/jsobjref/PrintPaperOptions.html#jsobjref-printpaperoptions
customPaper.name = "Tabloid";
// i have yet to figure out how to set custom paper sizes like below
// customPaper.name = "Custom";
// customPaper.width = doc.width;
// customPaper.height = doc.height;

// set coordinate options
// https://ai-scripting.docsforadobe.dev/jsobjref/PrintCoordinateOptions.html?highlight=page%20setup
coordinateOptions.position = PrintPosition.TRANSLATECENTER;

// set all separation options
// https://ai-scripting.docsforadobe.dev/jsobjref/PrintColorSeparationOptions.html#jsobjref-printcolorseparationoptions
sepOptions.convertSpotColors = false;
sepOptions.overPrintBlack = false;
sepOptions.colorSeparationMode = PrintColorSeparationMode.HOSTBASEDSEPARATION;

// actually print the file
doc.print(options);

 

Votes

Translate

Translate

Report

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
Engaged ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hey, I just realized I left out the important most pertinent part of the script 🤦‍:male_sign: (too much copying and pasting)...

 

The bottom of the script should read...

 

// disable all inks except last
var newInkList = doc.inkList;
for (var i = 0; i < newInkList.length - 1; i++) {
  alert(i);
  newInkList[i].inkInfo.printingStatus = InkPrintStatus.DISABLEINK;
}
sepOptions.inkList = newInkList;

// actually print the file
doc.print(options);

 

But when fixing this post, I ran another test because my initial doc didn't actually have any process colors in it. It only had a handful of custom spot colors I created, so it worked fine for me.

 

After trying a bunch of different ways to make this work, I don't think you can actually disable the CMYK inks if those colors are present in the art. If they aren't present (like in my initial file) they obviously don't print. Even though their printingStatus is disabled in the sepOptions right before calling `doc.print(options)`, it seems Illustrator just ignores that.

 

I'm able to easily disable custom spot colors with this script just not the CMYK process colors 🤷‍:male_sign:.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jun 26, 2022 Jun 26, 2022

Copy link to clipboard

Copied

LATEST

Hi,

Thank you for trying!

That's disapointing, because manuly disabling process inks works great. Bad luck for me...

 

I will search oppurtunity to script ink replacement, so all process colors would be spot and therefore valid for disabling.

 

Will update,

Regards,

Or

Votes

Translate

Translate

Report

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