Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

question about print button


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:, "0", ( -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


Level 10


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";, "0", ( -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.


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


Level 10


the confirmation message cannot be supressed in any way.

I don't know a better solution than this.