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

Setting the screen angle and frequency in ExtendScript

Engaged ,
Jan 22, 2020 Jan 22, 2020

Copy link to clipboard

Copied

I am revisiting an issue that has always vexed me: Setting the angle and frequency of halftones in ExtendScript.

 

There appear to be two places where this can be set:

  1. in a PrinterPreset
  2. in PrintPreference

 

I'd prefer to use the latter, but every time I attempt to do so:

var mydpp = document.printPreferences;

mydpp.blackAngle = 75;
mydpp.blackFrequency = 65;

I am immediately stopped at the `mydpp.blackAngle` assignment with the error message: "The property is not applicable in the current state." Is there any way to make this work?

 

The reason I cannot use the `PrinterPreset` method is because it overwrites other settings. Given the following example:

var mydpp = document.printPreferences;

var tempPreset = app.printerPresets.add({name:"tempPreset"});
tempPreset.blackAngle = 75;
tempPreset.blackFrequency = 65;

mydpp.activePrinterPreset = tempPreset;

mydpp.printFile = new File("somevalidfilehere.ps");

 

The moment that last line is executed, all the settings in `tempPreset` are lost because `mydpp.activePrinterPreset` is now set to nothing instead of `tempPreset`.

 

However, if I swapped those last two lines so that we assign the `activePrinterPreset` after `printFile`, then the moment `activePrinterPreset` is assigned, everything else gets lost, including `printFile`. It's incredibly frustrating, thus the reason why I'd prefer to set the Angle and Frequency directly on PrintPreference rather than through a PrinterPreset.

 

Any ideas?

TOPICS
Print , Scripting

Views

1.4K

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
Enthusiast ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

You might try saving the current settings for the default present and then change the settings (rather than creating a new preset). Reset the settings back when you are done. Just a thought.

 

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 ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

Hey, @S_Hopkins, thanks for responding.

 

I'm pretty sure that changing the settings for the default preset wouldn't make any difference. I would still be assigning it first in the same manner:

var tempPreset = app.printerPresets.itemByName("Default");

The rest of the code would be the same and the result would, likewise, be the same. I don't know this for certain, however, and I am willing to give it a try. Due to other obligations, though, I won't be able to test this until the middle of next week.

 

Also, I have noticed that `.printFile` is a property of `PrinterPreset` as well, so an alternative take would be to create a separate preset for each type of PostScript file creation that we need to do. (Because our OYO imagesetters need this.)

 

All of this, of course, is simply because ExtendScript refuses to let me set the frequency values directly on `PrintPreferences` (perhaps due to a bug?). 😞

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 ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

I doesn‘t look like you can set angles with postscript set as the printer. If I set printer to an available RIP that allows Separations, and call the tempPreset with the print command it works:

 

 

 

var mydpp = document.printPreferences;
var tempPreset = app.printerPresets.add({name:"tempPreset"})
mydpp.activePrinterPreset = tempPreset;

with(tempPreset){
  //this is an available postscript RIP
  printer = "7600 ART PRINT V2 @ CatbirdRIP"; 
  
  //setting Printer.postscriptFile throws an error on the blackAngle line
  //printer = Printer.postscriptFile;
  
  PPD = "PowerRIPX (Epson Stylus Pro 7600)"; 
  colorOutput = ColorOutputModes.separations; 
  blackAngle = 75.0;
  blackFrequency = 65.0
}

document.print(true, tempPreset);
tempPreset.remove();

 

 

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 ,
Jan 24, 2020 Jan 24, 2020

Copy link to clipboard

Copied

AppleScript doesn’t seem to have the postscript limitation. This works:

 

tell application id "com.adobe.indesign"
	activate
	set npp to make new printer preset with properties {name:"Temp", PPD:"Adobe PDF 9.0", printer:postscript file, color output:separations, black angle:75.0, black frequency:65}
	print active document using npp with print dialog
	delete npp
end tell

 

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 ,
Jan 25, 2020 Jan 25, 2020

Copy link to clipboard

Copied

Hi Rob,

I'm not sure, but I think it depends on the used PPD and the RIP what you can do or what is accepted.

 

You could try to enforce an angle/frequency combination by scripting.

My tests with InDesign 2020 and a printer preset for separations and PostScript with PPD "Adobe PDF"  throws NO errors when I try to apply a new angle and a new frequency value for black separations.

 

But this new angle and frequency values did not make into the written PostScript file ( my assumption ) and the distilled PDF. FWIW: Preserve Halftone Info was checked in my used joboptions with Distiller.

 

Ran the preflight profile: "Page is a separate plate" on the distilled PDF with Acrobat Pro.

In the Page information > Graphic State properties > Type 1 halftone I saw into Screen Frequency and Screen Angle.

 

The default for black was used:

Screen frequency: 70.710999
Screen angle: 45.000000

 

Maybe the better way would be to provide a PPD with the changed angle/frequency combinations?

With the ADPDF9.PPD look into the section that comes after:

*% Color Separation Information =====================

 

Regards,
Uwe Laubender

( ACP )

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 ,
Jan 25, 2020 Jan 25, 2020

Copy link to clipboard

Copied

Maybe something has changed with 2020, I’m testing in 2018.

 

If I set the PPD to "Adobe PDF 9.0" I don’t get an error, but the PPD also doesn’t actually get changed, and if I add in colorOutput = ColorOutputModes.separations; I get an error "The property’s value is locked and cannot be changed.

 

If the Print dialog has some other PPD as the default, this throws the error because the PPD doesn’t actually change and device independent doesn’t allow separations

 

 

 

var mydpp = document.printPreferences;

with(mydpp){
    printer = Printer.postscriptFile;
    PPD = "Adobe PDF 9.0";
    colorOutput = ColorOutputModes.separations;
}

 

 

 

Over in AppleScript I can run this with no error, and the PPD changes, but the black angle and frequencies don't actually change!

 

 

 

tell application id "com.adobe.indesign"
	set p to "Users:fishercat:Desktop:print.ps" as alias
	set properties of print preferences of active document to {printer:postscript file, PPD:"Adobe PDF 9.0", color output:separations, print black:true, black angle:75.0, black frequency:65, print file:p}
	print active document without print dialog
end tell

 

 

 

This does work:

 

 

 

tell application id "com.adobe.indesign"
	activate
	set pf to "Users:fishercat:Desktop:print.ps" as alias
	set npp to make new printer preset with properties {name:"Temp", PPD:"Adobe PDF 9.0", printer:postscript file, color output:separations, black angle:75.0, black frequency:65, print file:pf}
	print active document using npp without print dialog
	delete npp
end tell

 

 

 

The equivalent JS doesn‘t work in CC2018. Can you try this in 2020?:

 

var mydpp = document.printPreferences;
var tempPreset = app.printerPresets.add({name:"temp"})
with(tempPreset){
  printer = Printer.postscriptFile;
  PPD = "Adobe PDF 9.0"; 
  colorOutput = ColorOutputModes.separations; 
  blackAngle = 75.0;
  blackFrequency = 65.0;
  printFile = "Users:fishercat:Desktop:print.ps";
}

document.print(true, tempPreset);
tempPreset.remove();

 

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 ,
Jan 25, 2020 Jan 25, 2020

Copy link to clipboard

Copied

Hi Rob,

I revisited my ExtendScript code now and could change the angle and frequency of the saved PostScript file now.

Did not try it with a tempPreset yet.

 

What I did:

 

1. Used an already existing separation printer preset using PostScript and the "Adobe PDF"-PPD.

var sepPrintPresetName = "PS-Adobe-PDF-Separations";
var sepPrintPreset = app.printerPresets.itemByName( sepPrintPresetName );

 

2. Saved its properties to a variable:

var oldPresetProperties = sepPrintPreset.properties;

 

3. Changed angle and frequency in the preset.

sepPrintPreset.properties =
{
	printFile : docPSFile ,
	blackAngle : 75 ,
	blackFrequency : 150
};

 

4. Printed to PostScript.

doc.print( false , sepPrintPreset );

Distilled to PDF. Ran my preflight on the PDF with success.

Angle and frequency of Black has changed to the desired values:

PrintMeSeparated-2-CC-2020-AngleAndFrequency-BlackSep.PNG

 

5. Applied the old and saved properties to the used separation preset:

sepPrintPreset.properties = oldPresetProperties ;

 

6. Closed the document I printed without saving.

doc.close( SaveOptions.NO );

 

The last step was necessary, because I did not want to spoil the document's printPreferences.

I saw no other way to preserve the properties that I started with.

 

Regards,
Uwe Laubender

( ACP )

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 ,
Jan 25, 2020 Jan 25, 2020

Copy link to clipboard

Copied

Sturm359 said:

I am immediately stopped at the `mydpp.blackAngle` assignment with the error message: "The property is not applicable in the current state."

 

After experimenting a lot with app.printerPresets.add() I can tell:

The reason for this is very likely that the current state of printPreferences of your active document is not using Printer.POSTSCRIPT_FILE as value for property printer.

 

Unless you change this you even have no access to the value of ppdList, an array that is holding the currently available names of the PPDs in the form that are visible in the GUI. Not necessarily the names that come along with the PPD files.

 

So there are two strategies for this:

1. Work with a printerPreset that is already known and fulfill all requirements for separation.

Change the values for frequency and angles there. Print your PostScript file. Reset the properties of the used printer preset. Close the document without saving.

 

2. Or change the printPreferences of the active document with property printer first, then add a new temp printer preset with all necessary properties, print to PostScript, remove the temp printer preset and close the active document without saving.

 

Regards,
Uwe Laubender

( ACP )

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 ,
Jan 25, 2020 Jan 25, 2020

Copy link to clipboard

Copied

Hi Uwe,

In CC2018 I can run this:

 

var mydpp = document.printPreferences;
var tempPreset = app.printerPresets.add({name:"temp"})

with(tempPreset){
  printer = Printer.postscriptFile;
}

document.print(true, tempPreset);
tempPreset.remove();

 

and get this Print dialog

 

Screen Shot 19.png

 

If I add the Acrobat PPD:

 

var mydpp = document.printPreferences;
var tempPreset = app.printerPresets.add({name:"temp"})


with(tempPreset){
  printer = Printer.postscriptFile;
  PPD = "Adobe PDF 9.0"; 
}

document.print(true, tempPreset);
tempPreset.remove();

 

There are no errors, but I get the same Print dialog with the PPD as Device Independent

 

Screen Shot 20.png

 

If I add separations, I get the error

 

Screen Shot 21.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 ,
Jan 26, 2020 Jan 26, 2020

Copy link to clipboard

Copied

Hi Rob,

yes, that will fail.

You have to change the printPreferences of the document as a first step.

// Before that all other things will fail:
app.documents[0].printPreferences.printer =  Printer.POSTSCRIPT_FILE ;

 

The next step on an unknown configuration would be to check if the right PPD is there and then working with a temp printer preset. More precise: We can only check for the right name of the PPD.

 

Something like that:

 

// NOW we can look for the right PPD we need in the printer preset:
var ppdNameArray = app.documents[0].printPreferences.ppdList ;
var adobePPDName = "";

for( var n=0; n<ppdNameArray.length; n++ )
{
	if( ppdNameArray[n].match(/^Adobe PDF/) )
	{
		adobePPDName = ppdNameArray[n] ;
		break
	};
};

if( adobePPDName == "" )
{ 
	
	alert( "No Adobe PPD found. | SCRIPT" );
	
	exit();
	
};

/*
	WARNING:
	All NOT-DEFINED properties will be substituted with values that currently apply.
*/


var sepPrintPreset = app.printerPresets.add
(
	{
		printer : Printer.POSTSCRIPT_FILE ,
		ppd : adobePPDName ,
		colorOutput : ColorOutputModes.SEPARATIONS ,
		dataFormat : DataFormat.ASCII ,

		flip : Flip.NONE ,
		pagePosition : PagePositions.CENTERED ,
		printPageOrientation : PrintPageOrientation.PORTRAIT ,
		
		blackAngle : 75 ,
		blackFrequency : 150
		
		/* AND MANY MORE */
	}
);

 

Regards,
Uwe Laubender

( ACP )

 

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 ,
Jan 26, 2020 Jan 26, 2020

Copy link to clipboard

Copied

The problem I‘m running into is when the current Print default is a printer with no PPD.

 

If Print is this:

 

Screen Shot 22.png

 

Then the first line of your script throws this error, apparently because there is no PPD list:

 

Screen Shot 23.png

 

I think the OP would prefer to avoid a Print Preset, which may or may not exist on different machines.

 

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 ,
Jan 26, 2020 Jan 26, 2020

Copy link to clipboard

Copied

I can add this line at the top of your script:

 

app.documents[0].printPreferences.printer=Printer.POSTSCRIPT_FILE;

 

And I don’t get the error, but in CC2018 the PPD does not get loaded into the Print dialog—it does get included with the created preset. So I think you would have to include a Print command that calls the new preset and then delete the preset, otherwise a new preset will be created with each run of the script.

 

Thi works for me:

 

//the existing .ps file to print to
var pf = "Users:fishercat:Desktop:print.ps"

//make sure the printer is postscript so the PPD list is available
app.documents[0].printPreferences.printer=Printer.POSTSCRIPT_FILE;

// NOW we can look for the right PPD we need in the printer preset:
var ppdNameArray = app.documents[0].printPreferences.ppdList ;
var adobePPDName = "";

for( var n=0; n<ppdNameArray.length; n++ )
{
	if( ppdNameArray[n].match(/^Adobe PDF/) )
	{
		adobePPDName = ppdNameArray[n] ;
		break
	};
};

if( adobePPDName == "" )
{ 
	
	alert( "No Adobe PPD found. | SCRIPT" );
	
	exit();
	
};

/*
	WARNING:
	All NOT-DEFINED properties will be substituted with values that currently apply.
*/


var sepPrintPreset = app.printerPresets.add
(
	{
        printFile : pf,
		printer : Printer.POSTSCRIPT_FILE ,
		ppd : adobePPDName ,
		colorOutput : ColorOutputModes.SEPARATIONS ,
		dataFormat : DataFormat.ASCII ,

		flip : Flip.NONE ,
		pagePosition : PagePositions.CENTERED ,
		printPageOrientation : PrintPageOrientation.PORTRAIT ,
		
		blackAngle : 75 ,
		blackFrequency : 150
		
		/* AND MANY MORE */
	}
);

//the preset has to get called with the print command
app.documents[0].print(false, sepPrintPreset);
//delete the created preset or a new preset will be created with each run
sepPrintPreset.remove();

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 ,
Jan 26, 2020 Jan 26, 2020

Copy link to clipboard

Copied

Sorry Rob,

I thought I made it clear that the first line has to come before.

Otherwise all lines below will fail.

 

Regards,
Uwe Laubender

( ACP )

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 ,
Jan 26, 2020 Jan 26, 2020

Copy link to clipboard

Copied

I read too fast.

 

What seems like a bug is when I wrap all the desired Print settings in a properties object, in that case I don’t get any errors, but everything gets set as expected except for the blackAngle and blackFrequency. If I then try to set the black angle with another line I get an error:

 

 

app.documents[0].printPreferences.properties = {
        //printFile : pf,
		printer : Printer.POSTSCRIPT_FILE ,
		ppd : "Adobe PDF 9.0" ,
		colorOutput : ColorOutputModes.SEPARATIONS ,
		dataFormat : DataFormat.ASCII ,
		flip : Flip.NONE ,
		pagePosition : PagePositions.CENTERED ,
		printPageOrientation : PrintPageOrientation.PORTRAIT ,
		
		blackAngle : 75 ,
		blackFrequency : 200,
	}

//throws an error?!
app.documents[0].printPreferences.blackAngle = 45;

 

 

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 ,
Jan 31, 2020 Jan 31, 2020

Copy link to clipboard

Copied

Wow, I had no idea my question was going to spark such a discussion. Thanks for all of your replies and suggestions, folks!

 

Firstly, I apologize for not being more specific about my environment. I am running these scripts on Windows 10, so @rob_day's AppleScript suggestions will not help me, I'm afraid. Also, Rob, I'm pretty sure Printer.postscriptFile doesn't exist; the enum should read Printer.POSTSCRIPT_FILE. That might explain why you were having many errors in your earlier posts.

 

With that said, I believe I've finally gotten it to work, and here are some of my notes about it:

 

  1. Document.printPreferences.printer needs to be set to Printer.POSTSCRIPT_FILE first, as @Laubender has stated more than once. This is necessary in order to get a list of PPDs available for that printer with PrintPreference.ppdList. This can then be used in the next step:
  2. Next, Document.printPreferences.ppd needs to be set to one that supports separations. Most people here are choosing "Adobe PDF" for this, but our company uses RTI RIP-Kit, so we use the "RTI RIP-Kit v4" PPD. Same difference. This is necessary in order to "unlock" many other settings. For example, to get a list of paper sizes with PrintPreference.paperSizeList or to set all the separations properties, such as PrintPreference.blackAngle and PrintPreference.blackFrequency. Definitely don't choose "Device Independent", as that won't allow you to do those things.
  3. All settings (except for .pageRange) should be set on a PrintPreset. I still cannot set the .<color>Frequency nor .<color>Angle on PrintPreference (as @rob_day noted in his last post), so I have to use a PrintPreset. Side note: Our script just keeps re-using that same "tempPreset" for all jobs, setting its properties according to the specifics of the print job automatically. Thus, a ton of new presets doesn't get saved and there's no need to remove the preset when we're done with it.
  4. Print using the two-parameter signature, as noted by both @Laubender and @rob_day. I had been setting the PrintPreset with Document.printPreferences.activePrinterPreset, but that doesn't seem to work anymore. Now I find that Document.print(false, tempPreset) is what works for me.

 

Having spent most of the day on this problem and gotten through it with your help, I feel much better now. Thank you all so much!

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 ,
Jan 31, 2020 Jan 31, 2020

Copy link to clipboard

Copied

LATEST

Happy to hear you have something working.

 

Just a note the InDesign JS Guide samples has an annotated file on setting print preferences named PrintPreferences.jsx, which is sort of helpful. The example uses printer = Printer.postscriptFile; and I found that will work as well as Printer.POSTSCRIPT_FILE. There is no explanation as to why once you have the postscript printer loaded along with a valid PPD you can’t set the angles simply using print preferences, and skip the preset creation.

 

Here’s the guide code in a zip archive:

http://www.zenodesign.com/forum/PrintPreferences.zip

 

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