Copy link to clipboard
Copied
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
1 Correct answer
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Right!
Custom print button is definitely an option, but well... doesn't prevent a user from printing directly.
As a matter of fact, I did ask this question for both helping an OP and for my own learning purpose to improve my Acrobat skills and understanding.
The question was asked Can I make Pages with print only layers to not be visible when exporting an interactive pdf? by an OP on the Indesign Forum, and I thought it was an interesting one.
Anyhow, thanks for you help, I did learn more about the Willprint event.
Regards
Vinny

