Copy link to clipboard
Copied
Is it possible to control whether or not an entire page prints using a radio button?
For example: If option A is selected, Page 8 does not print. If options B or C are selected, Page 8 will print.
Pages don't have that property, fields do.
But yes, you can specify which pages to print if you use a script.
Here's an example of a script that will print (or more precisely, open the Print dialog with those pages pre-selected) pages 1-4, 6 and 8-10:
var pp = this.getPrintParams();
pp.printRange = [[0,3], [5,5], [7,9]];
this.print(pp);
Copy link to clipboard
Copied
Yes this is possible with JavaScript.
You can use a script to change the properties of an object (in this case a page) from visible to "visible but doesn't print" when a radio button is ticked, or, you can also achieve this with the "printParams" method.
The this.print() method will execute the print action immediately, for example. I am not sure if this is what you want.
While if you just change the page properties from visible to visible but doesn't print when a radio button is checked, it allows you to continue to work with the form normally; the user can print at the end when every other portion of the document is filled in completely.
Copy link to clipboard
Copied
Thank you!
Can you give an example of the code I would use to change the page properties when a radio button is checked?
Would the code be different if I use a check box?
Copy link to clipboard
Copied
While you can decide which pages to print when you call the print command, you can't do so when the user goes to File - Print themselves. What can be done, though, is to place a large white button fields (for example) on top of the page and change its visibility from Hidden (when you want the page to be printed) to Hidden but Printable (when you don't want it to be printed. That the user won't be able to overcome, at least not easily, and the page will print as a blank page.
Copy link to clipboard
Copied
Thank you!
As this is the case, I will place a button on my document that issues the Print command, and discourage my team from using the Ctrl + P shortcut or File - Print.
Is there a specific way to code this button to issue the print command that will only print the pages that have the "Visible but Does Not Print" property?
Copy link to clipboard
Copied
Pages don't have that property, fields do.
But yes, you can specify which pages to print if you use a script.
Here's an example of a script that will print (or more precisely, open the Print dialog with those pages pre-selected) pages 1-4, 6 and 8-10:
var pp = this.getPrintParams();
pp.printRange = [[0,3], [5,5], [7,9]];
this.print(pp);
Copy link to clipboard
Copied
Thank you for clarifying try67.
I apologize if this caused any confusion... I am also learning JavaScript and sometimes I post messages without reverifying the information. I am working harder to get better at this.
Copy link to clipboard
Copied
Excellent! Thank you for your quick replies Try67!
Would I need to set this as a Document Script in order to adjust the printRange properties depending on conditions in the form?
If, for example, I want to only print Page 8 if the box is checked:
if(event.target.isBoxChecked(0)) {
pp.printRange = [[0,7],[9,13]];
} else {
pp.printRange = [[0,13]];
}
PS I've barely begun using conditionals, so please let me know if this formatting is not correct.
Copy link to clipboard
Copied
Yes, that's pretty good, only if you use it from anywhere outside the check-box (or radio-button) field itself then you can't use event.target to access that value. You need to use this.getField("FieldName"), instead.
The rest of the code seems fine.
Copy link to clipboard
Copied
Thank you.
In the event that I want to have multiple boxes that control the print-ability of different pages, is there a way to do that? Like, some way to subtract a targeted page from the print queue?
If I use the script above on one checkbox to set one page to not print, then use the same code for a different page, it would reset the first page I wanted to not print. (I'm sure there's a better way to say this... sorry)
I suppose I could make one long Document Script that contains all of the possible print conditions in a lengthy if-else if... scenario, but I hope there is a better way to achieve this?
Copy link to clipboard
Copied
Removing elements from an array is possible, but kind of tricky. Adding them is easier.
You can do it by creating first an empty array (or one that contains those pages you want to print no matter what, and then add the rest of the pages based on the selections. Either way it will be a long set of if-statements, I think.