Many times you required to giving a printable option on your web project. If you are working on this kind of project and looking for a simple solution for that, then this tutorial will help a lot. In this article, we’ll provide a simple way to print a specific area of the web page. Using PrintArea jQuery plugin, you can easily print a part of a web page or full page content.
PrintArea jQuery Plugin designed to print specified areas of a web page. This plugin lets you specify 2 modes of printing, IFRAME-mode and Popup-mode. IFRAME-mode is discrete and popup mode opens a separate browser window.
Atfirst you should need to include the jQuery library (jquery.js
) and PrintArea jQuery plugin (jquery.PrintArea.js
).
<script src="jquery.js"></script> <script src="jquery.PrintArea.js"></script>
Write the following JavaScript for trigger the PrintArea jQuery plugin. In mode variable, you can specify two modes, iframe or popup.
<script> $(document).ready(function(){ $("#printButton").click(function(){ var mode = 'iframe'; //popup var close = mode == "popup"; var options = { mode : mode, popClose : close}; $("div.printableArea").printArea( options ); }); }); </script>
The following HTMl contains a print button and contents for print.
<a href="javascript:void(0);" id="printButton">Print</a> <div class="printableArea"> All the printable content goes here...... </div>
Using this script you can print not only a part of the web page, but also the full page content. Just attach id or class of the respective div with printArea()
function. You can get the jquery.PrintArea.js
file and all the source code from the downloadable package.
Do you want to get implementation help, or enhance the functionality of this script? Click here to Submit Service Request
how can we get which printer is connect and what sizes of paper they can print
how can we remove the header and footer url link using this library
Nice Tutorial i have one question how can hide page url from the print page
GOOD JOB! THANKS FOR THIS!!
Thanks. Very useful
thanks ,but we are in java
I need your help.I want to download as pdf directly without that print popup.
Check this tutorial, it may help to fulfill your requirement – http://www.codexworld.com/convert-html-to-pdf-php-dompdf/
Thanks Very nice work. I need some help from you. I implemented all code.I want to print modal content. But When i m going click print button nothing happens. Cant open print window, Please helpme
Thanks Very nice work. I need some help from you. I implemented all code.I want to print modal content. But When i m going click print button nothing happens. Cant open print window, Please helpme
Thanks. Very useful tool
Nice and helpful
very useful.