Skip to main content
Inspiring
July 23, 2018
Question

document.print()?

  • July 23, 2018
  • 3 replies
  • 1877 views

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.

This topic has been closed for replies.

3 replies

Legend
July 23, 2018

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);

Kukurykus
Legend
July 23, 2018

I also tried before other shortneded version, but like with this, it gave message about incompatibility, so I kept original one.

frmorelAuthor
Inspiring
July 24, 2018

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.


OK, I recorded this Action, but I don't understand the goal. Of course, when I play this Action, nothing visible happens.

Tom Ruark
Inspiring
July 23, 2018

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.

frmorelAuthor
Inspiring
July 23, 2018

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..."

Tom Ruark
Inspiring
July 23, 2018

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;

Kukurykus
Legend
July 23, 2018

It gives error in CS6 EXTENDED in fact, but in CC 2018 doesn't:

executeAction(stringIDToTypeID('print'), undefined, DialogModes.ALL)

frmorelAuthor
Inspiring
July 23, 2018
  1. 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

Kukurykus
Legend
July 23, 2018

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, 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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