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

Aug 31, 2017

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

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.

TOPICS
Acrobat SDK and JavaScript

Views

335

Likes

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

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

Aug 31, 2017

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

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.

TOPICS
Acrobat SDK and JavaScript

Views

336

Likes

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
Aug 31, 2017 0
Aug 31, 2017

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.

Likes

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
Reply
Loading...
Aug 31, 2017 0
Aug 31, 2017

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?

Likes

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
Reply
Loading...
Aug 31, 2017 0
Aug 31, 2017

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

Likes

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
Reply
Loading...
Aug 31, 2017 1
Aug 31, 2017

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

Likes

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
Reply
Loading...
Aug 31, 2017 0
Aug 31, 2017

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.

Likes

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
Reply
Loading...
Aug 31, 2017 0
vinny38 LATEST
Aug 31, 2017

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

Likes

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
Reply
Loading...
Aug 31, 2017 0