Trick How To Print Report Without Open New Tab Page With Javascript

The simple trick to print reports without opening a new tab page or open a PDF file in a new tab in the browser. Usually for web applications if you want to print reports, web programmers make PDF reports using class libraries such as FPDF which are then displayed in a new tab. The problem is how do we display the print dialog without opening the report page. Of course using javascript. Okay, just follow the short tutorial below.

How To Print Report Without Open New Tab In Browser

I am not the first person to invent this technique, I get this way from the site The basic concept of this way is browser will load the report pages that will be printed into a hidden iframe. hen on page report, will add JQuery code to open the print dialog.

Please see the following video preview of how this script works:

Tutorial print report without open new page with Javascript

1. Create an index.php file and copy the following code :

2. Create 2 pieces of files with names invoice.php, invoice2.php

3. Copy the following code and copy to the invoice.php

5. Please copy the invoice template from and paste to the invoice2.php

6. Put index.php, invoice.php, invoice2.php in one folder

7. Open a browser and run index.php

Finished , please run it on your browser


Similarly, a brief article about how to print the report without open new page with javascript

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.