Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Guide ,
Aug 31, 2017 Aug 31, 2017

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

TOPICS
Acrobat SDK and JavaScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 31, 2017 Aug 31, 2017

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.

Translate
Community Expert ,
Aug 31, 2017 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 31, 2017 Aug 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2017 Aug 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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 31, 2017 Aug 31, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2017 Aug 31, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 31, 2017 Aug 31, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines