Skip to main content
vinny38
Legend
August 31, 2017
Answered

Willprint... javascript code is triggered after the actual print

  • August 31, 2017
  • 1 reply
  • 1710 views

Hi JS experts.

I'm having hard time understanding how Willprint document action actually works.

As it sounds, it should allow a js code to be triggered just after the Print button is hit, and obviously before the real printing.

But I got this situation where code is triggered after the printing... which would be a Didprint behavior as I understand it...

Code is about spawning a template:

a=getTemplate("myTemplate");

a.spawn();

Doc prints without the spawned page and then adds it.

Thanks in advance for your enlightening help...

Vinny

This topic has been closed for replies.
Correct answer try67

Hmmmm... sounds like a great guess.

Problem is that page range is set to "ALL".

Could than mean than somehow Acrobat stores "All pages" as a value based on the actual document and set it as a range...? No matter if pages are inserted or spawned before the actual printing.

That could make sense, and would explain the issue...

But that would also mean that I would be stuck on that one. Unless you'd have a brilliant idea to tweak this out...


Yes, that's what's probably happening "behind the scenes".

The only solution I can think of is to add your own "Print File" button to your file, which will execute the spawn method and then call the print dialog.

1 reply

try67
Community Expert
Community Expert
August 31, 2017

The WillPrint event is triggered after the Print button in the Print

dialog button is clicked, and before the file is actually printed.

This is not ideal, admittedly, as any changes the script will implement in

the printed file are not visible in the Print dialog, which can be

confusing.

vinny38
vinny38Author
Legend
August 31, 2017

Thanks for your answer try67.

This is how I hoped it would work (nevermind the Print Dialog).

But for some reason, my "spawning" code does not work that way... As I said, document prints without the spawned page and then adds it.

Any idea why?

try67
Community Expert
Community Expert
August 31, 2017

My guess is it's an issue with the page range. If in the Print dialog it is set to print pages 1-3 and then you spawn page 4, it won't be included in the printed copy, even if it is created before it...