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

print document without click "print" from window

Explorer ,
May 20, 2021 May 20, 2021

Copy link to clipboard

Copied

Hello everyone
I'm looking for a script that will print a page for my "Xerox Phaser 3020" printer - no menu selection (because I print a lot of pages during the day).
The definition "fit to paper" should be.

 

[Please note that they wrote me a code in the past - but it only worked if you had already printed one page directly from the menu. And I'm looking for a script that will print without selecting "Print" from the menu anyway.]

TOPICS
Scripting

Views

673

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 Expert ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

I don't actually have a printer, so i can't test this completely.. but this script does indeed send a job to my print queue.. so it should work if there's a printer there.

https://github.com/wdjsdev/public_illustrator_scripts/blob/master/print_active_document.js

//Author: Dilliam Wowling
//email: illustrator.dev.pro@gmail.com
//github: github.com/wdjsdev/public_illustrator_scripts
//Adobe Forum Post: https://community.adobe.com/t5/illustrator-discussions/print-document-without-click-quot-print-quot-from-window/td-p/12051975
//Language: javascript/extendscript
//Script Name: Print Document
//deSCRIPTion: Sets up print options and prints the active document with no dialogs.


//Was this helpful? 
//Did it save you time and money?
//Would you like to say thanks by buying me a cup of
//coffee or a new car or anything in between?
//https://www.paypal.me/illustratordev


#target Illustrator

function PrintDocument()
{
	//set the name of the printer
	const nameOfPrinter = "Xerox Phaser 3020";

	if(!app.documents.length)
	{
		alert("Please open a document before running this script.");
		return;
	}

	const doc = app.activeDocument;

	//verify that the desired printer is in the printerList
	var pl = app.printerList;
	try
	{
		myPrinter = pl[nameOfPrinter];
	}
	catch(e)
	{
		alert("Failed to find a printer named " + nameOfPrinter);
		return;
	}

	//set up print options
	var	printOptions = new PrintOptions(),
		printCoordinateOptions = new PrintCoordinateOptions();
	
	printOptions.printerName = nameOfPrinter;
	printCoordinateOptions.fitToPage = true;
	printOptions.printCoordinateOptions = printCoordinateOptions;

	//print the document
	doc.print(printOptions);


}
PrintDocument();



 

 

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
Explorer ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

i get the error: (atttached)Screen Shot 2022-03-31 at 5.19.52.pngScreen Shot 2022-03-31 at 5.19.57.png

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 Expert ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

Maybe this page can help you. There is some sample code at the bottom that might be a good test.

- Mark

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
Explorer ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

If it were possible to change from "custom" to "emulate adobe illustrator 6" via script it would probably help

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
Explorer ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

DilliamWowling, is it possible to write such a script?
Or a script that will only print in the "emulator adobe illustrator 6" profile?

 

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 Expert ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Did you try all the different values for PrintOptions.colorManagementOptions?

 

Try adding this to @Disposition_Dev's script after the line "printOptions.printCoordinateOptions ...":

var pcmo = new PrintColorManagementOptions();
pcmo.colorProfileMode = PrintColorProfile.CUSTOMPROFILE;
// pcmo.colorProfileMode = PrintColorProfile.PRINTERPROFILE;
// pcmo.colorProfileMode = PrintColorProfile.OLDSTYLEPROFILE;
// pcmo.colorProfileMode = PrintColorProfile.SOURCEPROFILE;

pcmo.intent = PrintColorIntent.ABSOLUTECOLORIMETRIC;
// pcmo.intent = PrintColorIntent.PERCEPTUALINTENT;
// pcmo.intent = PrintColorIntent.RELATIVECOLORIMETRIC;
// pcmo.intent = PrintColorIntent.SATURATIONINTENT;

printOptions.colorManagementOptions = pcmo;

 

I wondering if "PrintColorProfile.OLDSTYLEPROFILE" might be what you need. Please bear in mind that I have no idea what might your issue be as it is possibly specific to your printer and setup. This is just a case of trying all the options one after another. I've commented out the other options so if you move the starting "//" from the next option to the previous option you can run script each time to test. I don't have a printer here to test with either.

- Mark

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
Explorer ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Hi
I tried all the options and it does not work.

 

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
Explorer ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

When I change a profile from "custom" to "emulate adobe illustrator 6"
The script works. So if it is possible to write a script before printing to a profile that works, and after printing return to what it was, it will help.
Or in the first place print in a profile that works.

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 Expert ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

try this:

 

printOptions.printPreset = "emulate adobe illustrator 6";

 

(important to note that this is case sensitive. so if the preset is actually called "Emulate Adobe Illustrator 6" you'll need to type it that way or it'll throw an error.)

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 Expert ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

Well, I can reproduce exactly @aviel222's experience. All these scripts give me the same results as OP:

(a) the dialog "The Color Management settings are inconsistent." appears. If we set userInteractionLevel to UserInteractionLevel.DONTDISPLAYALERTS then this goes away and isn't the deal-breaker here.

 

(b) the actual error is thrown "Error: an Illustrator error occurred: 300 (',')" (note the weird char after the comma is \u0001).

 

I have tried the solutions here, here and here, with the same results.

 

My system is AI 26.2, MacOS 12.3, M1 chip. @aviel222 what is your system setup?

- Mark

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
Explorer ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

My system is 10.15.7

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 Expert ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

Okay, so we're both using MacOS. Can anyone else reading this confirm that they can print via script? We're trying to discover if it's a bug or just something that's changed and we don't know about.

- Mark

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
Explorer ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

Screen Shot 2022-04-02 at 19.45.10.png

This is the profile. but this dosn't work.

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 Expert ,
Apr 02, 2022 Apr 02, 2022

Copy link to clipboard

Copied

Yeah I couldn't work out how to choose "Emulate Adobe® Illustrator® 6.0" via a script anyway. This answer says how to do it (quite a strange way) but it doesn't work for me.

I also tried this (if you try this yourself—remember you'll have to set your color settings again afterwards):

function turnColorManagementOff() {
    var colorSettingsFiles = app.colorSettingsList,
        offSettingsFile;
    for (var i = 0; i < colorSettingsFiles.length; i++) {
        if (colorSettingsFiles[i].fullName.search(/Color Management Off/) != -1) {
            offSettingsFile = colorSettingsFiles[i];
            break;
        }
    }
    if (offSettingsFile == undefined) {
        alert('Couldn\'t turn color management off.');
        return;
    }
    app.loadColorSettings(offSettingsFile);
}

turnColorManagementOff();

This successfully set my color settings to "Color Management Off" but it wasn't the same as "Emulate Adobe® Illustrator® 6.0" (meaning that printing via script didn't work). NOTE: the above script will change your global colour settings file until you manually put it back to what it was!

 

So to summarise, like you, if I manually set Color Settings to "Emulate Adobe® Illustrator® 6.0" I *can* print via script, but any other settings causes the script to throw error.

 

@CarlosCanto@Silly-V do you mind if I ask you if you know anything about this? I'm stumped.

- Mark

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
New Here ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

Thanks. Is it possible to return at the end of the script to what it was?

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 Expert ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

You mean "turnColorManagementOff" script? I couldn't find a way to actually know what your current color settings are so, without that, no. There is App.defaultColorSettings which gives you "The default color settings file for the current application locale" but it isn't necessarily the active csf file.

- Mark

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
New Here ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

I think the change remains and I will always work in a profile that works well

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
New Here ,
Apr 03, 2022 Apr 03, 2022

Copy link to clipboard

Copied

I think we will give up the change and I will always work in a profile that works well

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
Explorer ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

LATEST

Hi. DilliamWowling
We are not done yet. I have something strange.


The printer ignores and prints according to the last print I printed
That is, if I previously printed a large page without matching paper
Then he prints and cuts the page in print

Do you have any idea why this is happening?

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