Silently Printing Your PDF

If you have ever had the need to give your end users a ‘Print’ button on the page then
read on.

Select the Form Field tool (see Figure 1.1), and draw a small button sized area on the page
(see Figure 1.2). When the Form Field dialog comes up give the Field a name (myButton) and
select ‘Button’ from the ‘Type’ list box (see Figure 1.3).

Figure 1.1

Figure 1.2

Figure 1.3

Click the ‘Actions’ tab and select the ‘Mouse Up’ event and click the ‘Add…’ button.
Select ‘JavaScript’ from the ‘Type’ listbox, and click the ‘Edit…’ button (see Figure 1.4).

Figure 1.4

Type the following Javascript code into the editor window (case sensitive) to (see Figure

Figure 1.5

Print the Current Page only:

this.print(false,this.pageNum, this.pageNum,false);    


Print from the current page to the end of the document:

this.print(false,this.pageNum, this.numPages,false);

The four parts of the javascript print command are:

  • True/False – Determines whether the ‘Print Dialog’ window is displayed.
  • Start Page Number
  • End Page Number
  • True/False – Determines whether the ‘Cancel’ print job dialog window is displayed.

You can type any valid page number in place of the ‘this.pageNum’ and ‘this.numPages’

Note: If you want to put some text on the ‘face’ of the button see below Figure 1.6 and
Figure 1.7.

Figure 1.6

Figure 1.7

You May Also Like

About the Author: Dave Wraight

Leave a Reply