The Accurate Info button on my form will make two last hidden pages on the form visible and set focus to the first field on the first Info page. The whole form has dynamic subforms and they can grow so I do not know the exact number of the pages at the end. I want to have a print button on these two Info pages that will print only them, not the entire form. Can someone please provide some help on this one.
Thank you,
Solved! Go to Solution.
Hi,
If you drag a standard print button onto the page, you will see that it has eight parameters:
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);
The second parameter specifies the start page "0", as the page numbers use a zero numbering system. The first page of your form is "0".
The third parameter specifies the last page to be printed. This is a basic calculation where xfa.host.numPages counts the total number of pages AND -1 brings this into the zero numbering system.
All you need to do is add a line to work out the page number that the print button is on (eg second plast page) and then use this information in parameters 2 and 3.
var vPage = xfa.layout.page(this);
xfa.host.print(1,(vPage -1).toString(), (vPage).toString(), 0, 1, 0, 0, 0);
The vPage will get the page number, counting from 1. The print parameters then use this information to set the start page and end page. No matter how many pages are ahead of the last two pages, this script will always print the page with the print button and the next page.
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
If you drag a standard print button onto the page, you will see that it has eight parameters:
xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);
The second parameter specifies the start page "0", as the page numbers use a zero numbering system. The first page of your form is "0".
The third parameter specifies the last page to be printed. This is a basic calculation where xfa.host.numPages counts the total number of pages AND -1 brings this into the zero numbering system.
All you need to do is add a line to work out the page number that the print button is on (eg second plast page) and then use this information in parameters 2 and 3.
var vPage = xfa.layout.page(this);
xfa.host.print(1,(vPage -1).toString(), (vPage).toString(), 0, 1, 0, 0, 0);
The vPage will get the page number, counting from 1. The print parameters then use this information to set the start page and end page. No matter how many pages are ahead of the last two pages, this script will always print the page with the print button and the next page.
Hope that helps,
Niall
Views
Replies
Total Likes
Thank you so much. You've explained it so well.
Views
Replies
Total Likes
Helped me too! many thanks Niall.
Views
Replies
Total Likes
Hi Niall,
How can this be modified to print just the last page?
I have a situation where I need to place a print button on a repeating subform which is the size of an entire page. If I place the print button on a master page it will automatically show up on every new instance. Hoe can I program the button to just print the last page which will always be the last instance?
Thanks in advance.
Shaun
Views
Replies
Total Likes
use xfa.host.print with the xfa.host.numPages to print just the last page
Views
Replies
Total Likes
TundraSteve - thanks for the reply.
I'm not sure I follow (pardon my lack of knowledge)
Do you mean: xfa.host.print(1, "0", (xfa.host.numPages).toString(), 0, 0, 0, 0, 0); //removed -1
or
xfa.host.print(1, "0", (xfa.host.numPages), 0, 0, 0, 0, 0); //removed -1 and .toString()
Neither seemed to work.
Thanks
Views
Replies
Total Likes