Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

question about print button

Avatar

Level 4

Good morning everyone,

Quick question for you this morning, im playing around with the print button and so far i get it to do what i want. Which is basically print in "FIT" mode like this:

 

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);

now this takes care of people who press my custom print button, but i dont have control over the folks that might activate that from the print icon or from the print menu options.

Now for this i know that using PRE:PRINT would solve it for sure, but i dont know how to write the code in there so it works.

What i did at first is copy the print code above in that section, but if i press my Print button where the same code is, i create a endless loop.

Im just trying to cover my self and make sure that what ever one of the 3 print choices they choose, i will be able to execute the code above and without any infinite loops

Any ideas how i could set this up?

Thank you very much again!!!

4 Replies

Avatar

Level 10

Hi,

you can disallow printing form the menu items or key combination with a bit of scripting.

But first you need a variable you add under the form properties with a default value like 0.

Lets name it "usedPrintButton".

Ok, now the scripting part.

There are 3 scripts in 3 different events neccassary. You can use all those events of your print button.

1. click event

// Modify the variable to imply user has started printing from this button

usedPrintButton.value = "1";

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);

2. prePrint event

// Check the variable and cancel printing when it's 0

if (usedPrintButton.value == "0") {

          xfa.event.cancelAction = true;

}

3. postPrint event

// Set the variable back to 0

usedPrintButton.value = "0";

Hope this helps.

Avatar

Level 4

thank you very much, this will work very well.

Avatar

Level 4

I implemented this and it works well, except that i get an Acrobar Reader message box saying that the print was canceled.

Can we hide this message at all?

If not, are there any other way to set my printing parameters to FIT on a button i make, the print menu, the print key combo or the print icon?

Thx again for all the help

Avatar

Level 10

Hi,

the confirmation message cannot be supressed in any way.

I don't know a better solution than this.