Skip to main content
Participating Frequently
September 11, 2020
Answered

Javascript - Control Whether Page Prints?

  • September 11, 2020
  • 2 replies
  • 1796 views

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.

This topic has been closed for replies.
Correct answer try67

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);

2 replies

try67
Community Expert
Community Expert
September 12, 2020

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.

Participating Frequently
September 14, 2020

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?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 14, 2020

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);

ls_rbls
Community Expert
Community Expert
September 12, 2020

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.

 

 

Participating Frequently
September 14, 2020

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?