Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Print based on boxes checked

Explorer ,
Feb 16, 2020 Feb 16, 2020

Below is a screenshot of the 2nd page of the PDF file (this page is referred to as the "journal").  As you can see,  some checkboxes are checked, which unhides the Total Pages column and shows the page number.

 

The PDF file contains many documents in it.  For example, SOC 295, checked marked in the journal is pages 10-17 of the PDF file.

 

I'd like to know if the following is possible AND what is the minimum type of Acrobat required to make it work (Reader, Standard, Pro)?

Is it possible to create a print button, that when clicked on, prints the correct docs/pages based on the checkboxes that are checked?  

 

Screenshot 2020-02-16 10.20.54.png

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , PDF forms , Print and prepress , Standards and accessibility
3.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2020 Feb 17, 2020

MODIFIED REPLY

 

NOTE: I am not able to use the reply button in this thread anymore so I am modifying this reply with the latest answer:

 

 

I think this form can work in Reader, and you should be able to accomplish this type of editing with Acrobat Pro and some javascripting.

 

If you're already using javascript for the unhide function in combination with the checkboxes, do you mind sharing the code that you're using?

 

Also, if I understood correctly, are you placing a print button right next to each unhidden field?

 

Try this as an example  template  for the print action or button:

 

app.alert("Document is now Printing");

var pp2 = this.getPrintParams();
pp2.firstPage = 2;
pp2.lastPage = 6;
pp2.interactive = pp2.constants.interactionLevel.automatic;
pp2.DuplexType = pp2.constants.duplexTypes.DuplexFlipLongEdge;
pp2.pageHandling = pp2.constants.handling.fit;
pp2.printerName = "";
if (this.getField("CH.2").value == "Yes") {this.print(pp2)};

var p2 = app.thermometer; 
p2.duration = this.print(pp2);
p2.begin();
for ( var i = 0; i < this.print(pp2); i++)
{
p2.value = i;
p2.text = "Printing pages 3-5"; break; 
}
p2.end(); 


var pp4 = this.getPrintParams();
pp4.firstPage = 9;
pp4.lastPage = 9;
pp4.interactive = pp4.constants.interactionLevel.automatic;
pp4.DuplexType = pp4.constants.duplexTypes.simplex;
pp4.pageHandling = pp4.constants.handling.fit;
pp4.printerName = "";
if (this.getField("CH.4").value == "Yes") {this.print(pp4)};

var p4 = app.thermometer; 
p4.duration = this.print(pp2);
p4.begin();
for ( var i = 0; i < this.print(pp4); i++)
{
p4.value = i;
p4.text = "Printing page 8"; break; 
}
p4.end();


var pp6 = this.getPrintParams();
pp6.firstPage = 11;
pp6.lastPage = 16;
pp6.interactive = pp6.constants.interactionLevel.automatic;
pp6.DuplexType = pp6.constants.duplexTypes.DuplexFlipLongEdge;
pp6.pageHandling = pp6.constants.handling.fit;
pp6.printerName = "";
if (this.getField("CH.6").value == "Yes") {this.print(pp6)};

var p6 = app.thermometer; 
p6.duration = this.print(pp6);
p6.begin();
for ( var i = 0; i < this.print(pp6); i++)
{
p6.value = i;
p6.text = "Printing pages 10-15"; break; 
}
p6.end();


var pp8 = this.getPrintParams();
pp8.firstPage = 17;
pp8.lastPage = 17;
pp8.interactive = pp8.constants.interactionLevel.automatic;
pp8.DuplexType = pp8.constants.duplexTypes.simplex;
pp8.pageHandling = pp8.constants.handling.fit;
pp8.printerName = "";
if (this.getField("CH.8").value == "Yes") {this.print(pp8)};

var p8 = app.thermometer; 
p8.duration = this.print(pp8);
p8.begin();
for ( var i = 0; i < this.print(pp8); i++)
{
p8.value = i;
p8.text = "Printing page 16"; break; 
}
p8.end();


var pp9 = this.getPrintParams();
pp9.printRange=[[22,22]]
pp9.printRange.push([23,24]);
pp9.interactive = pp9.constants.interactionLevel.silent;
pp9.pageHandling = pp9.constants.handling.fit;
pp9.printerName = "";
this.print(pp9);

var p9 = app.thermometer; 
p9.duration = this.print(pp9);
p9.begin();
for ( var i = 0; i < this.print(pp9); i++)
{
p9.value = i;
p9.text = "Printing pages 21-23"; break; 
}
p9.end();

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 17, 2020 Feb 17, 2020

here is the code to hide/unhide the textbox:

 

var nHide = event.target.isBoxChecked(0)?display.visible:display.hidden; this.getField("TotalPages_SOC295").display = nHide; this.getField("TotalPages_SOC295").display = nHide; this.getField("TotalPages_SOC295").display = nHide;

 

the print buttons are just set-up to issue a print command for that document only with specific parameters (number of pages, duplex vs simplex, etc)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 18, 2020 Feb 18, 2020

Hi, 

 

You can use something like this:

 

 

 

 

//this line is for a Mouse Up javascript action to print pages 10-17
if (this.getField("checkbox").value == "Yes") {this.print(true, 9,16)} ;

//use this line if you don't want the user to see the printing dialogue
if (this.getField("checkbox").value == "Yes") {this.print(false, 9,16)} ;


//Be aware that the first page in Adobe Acrobat starts at 0. So make sure that the start and end pages are input in the correct range in the script 

 

 

 

 

You can test the PDF that I created using your  screenshot of the "journal".

 

Here is the link: https://documentcloud.adobe.com/link/review?uri=urn%3Aaaid%3Ascds%3AUS%3A76d9d119-b2f7-4c8c-9cb3-0cc... 

 

Notice the print button is labeled so it becomes part of the form a little  more eye-appealing. See image below with a tooltip:

 

SOC295.png

 

I hope this helps. Good luck!

 

By the way, it works in Adobe Reader too. You might be able to also use it in the Reader Mobile app, because it partially worked with  a third-party app like Foxit Reader. I just don't know why it doesn't work in the Adobe Reader mobile app.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2020 Feb 20, 2020

hi ls_rbls,  I appreciate the effort in offering help... your approach might be the right path, but I just know for sure.

My original question was slightly different... I need the ability to have a single print button that can print all the pages that are checked.

So if only 295 is checked and user clicks on the print button, then it should just print those pages. But say the user check marks 3 different documents, then when he hits the print button, it should print all 3 of those documents.  

 

Any idea on how to do that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 20, 2020 Feb 20, 2020

forgot to mention that I need it to print all the selected documents in a single print dialogue box,... so something like this will not work as it will just bring up multiple dialogue boxes

 

if (this.getField("CH.6").value == "Yes") {this.print(true, 7,8)} ;

if (this.getField("CH.5").value == "Yes") {this.print(true, 1,2)} ;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 21, 2020 Feb 21, 2020

You have to set  this.print to false like indicated in my first reply.

 

Like this, for example:

 

if (this.getField("CH.5").value == "Yes") {this.print(false, 1,2)} ;

if (this.getField("CH.6").value == "Yes") {this.print(false, 7,8)} ;

if (this.getField("CH.7").value == "Yes") {this.print(false, 11,20)};

 

True will pop up the print dialogue and False will print "silently" without showing the print dialogue.

 

The only issue I see with this option is that the user won't get a choice to change the type of printer unless it is done manually Control Panel---> Devices and Printers (if using windows). But it worked for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2020 Feb 22, 2020

In this thread i was just helping another user : https://community.adobe.com/t5/acrobat/add-margins-to-page-and-select-the-specific-printer/m-p/10940... 

 

The printing code in the link above is a more defined and robust method of printing if you want ot incorporate it into your PDF.

 

These are the references that I used:

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 23, 2020 Feb 23, 2020

ls_rbls, Thanks for the info.  I think silent print might work. 

 

How would you write THAT command above to also include the following parameters: Duplex printing and "fit" handling? ... 

 

pp.DuplexType = pp.constants.duplexTypes.DuplexFlipLongEdge;

pp.pageHandling = pp.constants.handling.fit;

 

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 23, 2020 Feb 23, 2020

Also, since it's doing silent print, most users who will use this PDF won't know that printing was started. 

I need a pop-up window after the print button is pressed that informs the user that "Document sent to default printer".

any idea on how to do that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2020 Feb 24, 2020

Hi,

 

You can try something like this:

 

var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.automatic;
pp.pageHandling = pp.constants.handling.fit;
pp.DuplexType = pp.constants.duplexTypes.DuplexFlipLongEdge;

//leave line below empty string to print to default printer
//It is my understanding that printerName is  feature in Windows only but see if it works in your Mac
pp.printerName = ""; 

if (this.getField("CH.6").value != "Off") {this.print({bUI: false, nStart: 11, nEnd: 16})

var t = app.thermometer; 
t.duration = this.numPages;
t.begin();
for ( var i = 0; i < this.numPages; i++)
{
t.value = i;
t.text = "Printing page" + (i + 1);
app.alert("Document is Printing"); break; // break if operation cancelled
}
t.end();
} 

 

 

Download all jscript resources from here: https://www.adobe.com/devnet/acrobat/documentation.html

 

All the answers that  I'm helping you with are there in those documents.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 24, 2020 Feb 24, 2020

ls_rbls,

thanks for reply.

 

I'm a bit confused on how that code would be formatted if multiple IF scenarios are being checked for... would the second IF be under the first? 

 

The problem is that different documents, signified by different check boxes have different print parameters... 

 

For example, lets say I have 10 check boxes total (CH.1- CH.10)... and I've check marked CH2, CH4, CH6, CH8

 

but the catch is that 2 and 6 need to print duplex, but 4 and 8 need to print one sided.... the code should know the print parametes of each IF scenario once the IF is activated via check box. 

 

What does the script need to look like in order to do that? 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2020 Feb 28, 2020
LATEST

Hi,

 

Just checking if you were able to work around the script.

 

Let me know if it helped.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines