Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Print last page only

Avatar

Level 6

Hi,

I'm looking for a script that will just print the last page in a document. My form has one repeating subform, and based on the way I have it setup, the last instance (which always lands on the last full page) is the one I need the user who opens the form to be able to print with one click of the print button.  This will help prevent them form having to indicate the page to be printed in the print window.

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The print method has eight parameters, which you can change to affect the printing. The second parameter is the start page and the third parameter is the finish/last page to be printed.

All you need to do is replace the second parameter "0", with the default third parameter (xfa.host.numPages -1).toString().

This should work:

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

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

The print method has eight parameters, which you can change to affect the printing. The second parameter is the start page and the third parameter is the finish/last page to be printed.

All you need to do is replace the second parameter "0", with the default third parameter (xfa.host.numPages -1).toString().

This should work:

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

Hope that helps,

Niall