Copy link to clipboard
Copied
Hello,
As app.activeDocument.print() throws a 8800 error in PSD CS6 (and also doesn't work with actions), is there another way to print active document.
I would like to show a personal UI before every printing. Maybe I could use listeners? But I don't understand how.
Thank you for your help.
Copy link to clipboard
Copied
It gives error in CS6 EXTENDED in fact, but in CC 2018 doesn't:
executeAction(stringIDToTypeID('print'), undefined, DialogModes.ALL)
Copy link to clipboard
Copied
- executeAction(stringIDToTypeID('print'), undefined, DialogModes.ALL)
gives the same error as wihen "Print" menu item (CMD-P) is called from actions with "Insert a command..."
CS 6, Photoshop 13.0, Mac OS 10.11.6
Copy link to clipboard
Copied
function sTT(v) {return stringIDToTypeID(v)}
(ref1 = new ActionReference()).putProperty(sTT('property'), sTT('printOutput'))
ref1.putEnumerated(sTT('document'), sTT('ordinal'), sTT('targetEnum'));
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(dsc2 = new ActionDescriptor()).putBoolean(sTT('postScriptColor'), true)
dsc2.putEnumerated(sTT('intent'), sTT('intent'), sTT('image'))
dsc2.putBoolean(sTT('printSixteenBit'), false)
dsc2.putString(sTT('printerName'), 'Adobe PDF');
(dsc3 = new ActionDescriptor()).putEnumerated(sTT('builtin'), sTT('builtinProof'), sTT('proofCyan'))
dsc2.putObject(sTT('printProofSetup'), sTT('proofSetup'), dsc3)
dsc1.putObject(sTT('printOutput'), sTT('printOutput'), dsc2);
(dsc4 = new ActionDescriptor()).putEnumerated(sTT('builtin'), sTT('builtinProof'), sTT('proofCyan'))
dsc1.putObject(sTT('printViewProofSetup'), sTT('proofSetup'), dsc4);
(dsc5 = new ActionDescriptor()).putBoolean(sTT('caption'), false)
dsc5.putBoolean(sTT('calibrationBars'), false)
dsc5.putBoolean(sTT('registrationMarks'), false)
dsc5.putBoolean(sTT('cornerCropMarks'), false)
dsc5.putBoolean(sTT('centerCropMarks'), false)
dsc5.putBoolean(sTT('labels'), false)
dsc5.putBoolean(sTT('negative'), false)
dsc5.putBoolean(sTT('emulsionDown'), false)
dsc5.putBoolean(sTT('interfaceIconFrameDimmed'), false);
(dsc6 = new ActionDescriptor()).putDouble(sTT('red'), 255)
dsc6.putDouble(sTT('grain'), 255)
dsc6.putDouble(sTT('blue'), 255)
dsc5.putObject(sTT('background'), sTT('RGBColor'), dsc6)
dsc5.putUnitDouble(sTT('borderThickness'), sTT('distanceUnit'), 0)
dsc5.putUnitDouble(sTT('bleed'), sTT('distanceUnit'), 0)
dsc5.putUnitDouble(sTT('resolution'), sTT('pixelsUnit'), 1)
dsc5.putBoolean(sTT('vectorData'), true)
dsc5.putEnumerated(sTT('pagePosition'), sTT('pagePosition'), sTT('pagePosCentered'))
dsc5.putUnitDouble(sTT('left'), sTT('distanceUnit'), 261.5)
dsc5.putUnitDouble(sTT('top'), sTT('distanceUnit'), 384.5)
dsc5.putUnitDouble(sTT('scale'), sTT('percentUnit'), 100)
dsc5.putBoolean(sTT('cropWhenPrinting'), false)
dsc5.putInteger(sTT('cropRectBottom'), 841)
dsc5.putInteger(sTT('cropRectLeft'), 0)
dsc5.putInteger(sTT('cropRectRight'), 595)
dsc5.putInteger(sTT('cropRectTop'), 0)
dsc1.putObject(sTT('printOutputOptions'), sTT('printOutputOptions'), dsc5);
(dsc7 = new ActionDescriptor()).putData(sTT('systemInfo'), String.fromCharCode(2, 0, 0, 0, 32, 110, 105, 87, 0, 0, 0, 0, 65, 0, 100, 0, 111, 0, 98, 0, 101, 0, 32, 0, 80, 0, 68, 0, 70, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 3, 6, 220, 0, 212, 5, 83, 239, 128, 1, 1, 0, 9, 0, 154, 11, 52, 8,
100, 0, 1, 0, 15, 0, 176, 4, 2, 0, 1, 0, 176, 4, 3, 0, 1, 0, 65, 0, 52, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
))
dsc1.putObject(sTT('osSpecificPrintInfo'), sTT('osSpecificPrintInfo'), dsc7)
dsc1.putString(sTT('caption'), '')
executeAction(sTT('print'), dsc1, DialogModes.ALL)
Copy link to clipboard
Copied
Unfortunately, printing is not very scriptable as the setup is unique for every machine + printer combination. If you manually print from the UI and then print from your script, does that work? Hopefully it does and you can capture the ScriptListener output as Kukurykus has above and use that in your script in the future. You will have to redo that for each printer you attach or if you change your settings manually.
Copy link to clipboard
Copied
Thank you for your replies.
Tom, I understand printing is not very scriptable. I just would like to trigger the standard Photoshop print dialog, the one is called with the menu item "File/Print..."
Kukurykus ,
your script works fine but of of course overrides my printing settings. I'm not familiar with ScriptListener at all but I'll try to use your script in a few days, when I will be connected again to my usual printer.
Copy link to clipboard
Copied
DialogModes.ALL is what is showing you the dialog. Just add this line before you call the .print() method.
app.displayDialogs = DialogModes.ALL;
activeDocument.print();
app.displayDialogs = DialogsModes.NO;
Copy link to clipboard
Copied
For me on CS6 EXTENDED it doesn't work.
Copy link to clipboard
Copied
Try this shorter version.
var d = new ActionDescriptor();
d.putObject(stringIDToTypeID("printOutput"), stringIDToTypeID("printOutput"), new ActionDescriptor());
d.putObject(stringIDToTypeID("printViewProofSetup"), stringIDToTypeID("proofSetup"), new ActionDescriptor());
d.putObject(stringIDToTypeID("printOutputOptions"), stringIDToTypeID("printOutputOptions"), new ActionDescriptor());
var d1 = new ActionDescriptor();
d1.putData(stringIDToTypeID("systemInfo"), 0);
d.putObject(stringIDToTypeID("osSpecificPrintInfo"), stringIDToTypeID("osSpecificPrintInfo"), d1);
executeAction(stringIDToTypeID("print"), d, DialogModes.ALL);
Copy link to clipboard
Copied
I also tried before other shortneded version, but like with this, it gave message about incompatibility, so I kept original one.
Copy link to clipboard
Copied
The message will always be if the printers are very different, for example, bw and color. There is a tick - do not show
Copy link to clipboard
Copied
For me, CS6, Photoshop 13.0:
- var d = new ActionDescriptor();
- d.putObject(stringIDToTypeID("printOutput"), stringIDToTypeID("printOutput"), new ActionDescriptor());
- d.putObject(stringIDToTypeID("printViewProofSetup"), stringIDToTypeID("proofSetup"), new ActionDescriptor());
- d.putObject(stringIDToTypeID("printOutputOptions"), stringIDToTypeID("printOutputOptions"), new ActionDescriptor());
- var d1 = new ActionDescriptor();
- d1.putData(stringIDToTypeID("systemInfo"), 0);
- d.putObject(stringIDToTypeID("osSpecificPrintInfo"), stringIDToTypeID("osSpecificPrintInfo"), d1);
- executeAction(stringIDToTypeID("print"), d, DialogModes.ALL);
works, as the longer version, though both gave message about incompatibility.
app.displayDialogs = DialogModes.ALL;
activeDocument.print();
app.displayDialogs = DialogsModes.NO;
doesn't work (always same buggy error).
Anyhow, thanks for your replies.
Copy link to clipboard
Copied
You can record an Action.
To do this, start Action recording.
Press Ctrl+P or manually call the Print menu.
In the window dialog click "Done", not "Print". (!!!!!!)
Stop recording.
Enable the Dialog display in this Action.
Copy link to clipboard
Copied
OK, I recorded this Action, but I don't understand the goal. Of course, when I play this Action, nothing visible happens.
Copy link to clipboard
Copied
Did you turn on dialogs in Action?
Actions can also be converted to a script.
Copy link to clipboard
Copied
Sorry, I wasn't clear enough.
I turned on dialogs, I recorded the Action and saw the printing dialog.
I was just saying that nothing visible happens when I play this Action. But, OK, I now understand it could be interesting to convert this action to a script .
Thank you.
Copy link to clipboard
Copied
When you run the Action or the converted script, you need to press the Print button