jQuery Print Plugin helps to print the content of a particular web page. To print contents of a page we have option of directly using ctrl+P but this plugin helps you to implement dynamic functionality like printing the input fields given or the selected content in particular section of the page.
This plugin supports the following unique options:
Table of Contents
How to use :
Add a jQuery library and jQuery print plugin.
<script src="jquery.min.js"></script> <script src="jQuery.print.js"></script>
Add an unique ID in your html element where you want to make it printable.
<div id="printable"> Your Content </div>
Add a button to print the specified html element.
<button class="print"> Print this </button>
Call the plugin on the print button.
Function: Whether or not the styles from the parent document should be included
This style is helpful in selecting or not selecting particular element in the page. As George Boole theory, Boolean refers to logic, function, expression. While using this option, “Boolean” may refer to: Boolean data type, a form of data with only two possible values (usually “true” and “false”).
Function: Whether or not link tags with media=’print’ should be included; Over-riden by the globalStyles option
This option is dependent on the previously given global style properties and its default given value if false. It is also Boolean data type and can be given true as well.
Function: URL of an external stylesheet to be included
CSS properties for the given code of the plugin is called using external stylesheet and it helps to design the colors and user interface of the webpage.
Acceptable-Values: Any valid jQuery-selector
Function: This function helps to select an item or set of items that are to be excluded from the webpage to be printed. For example if the user wants to print only given input fields then .no-print is used to rest of the page elements which helps to print only input fields, similarly if the user doesnt want to print header or footer part of the page such sections can be exluded.
Default: true, creates a hidden iframe if no-vaild iframe selector is passed
Acceptable-Values: Any valid jQuery-selector or Boolean
Function: This function decides if we need to print from a pop-up window or from a iframe. In the given Boolean value if true is selected, it prints from the iframe and if false is selected it prints from pop-up window. It takes jQuery-selector content from the existing values of the iframe.
Acceptable-Values: Any valid jQuery-selector or HTML-text
Function: If user wishes to inser specific content or values before or after the selected content this option is used and this helps to align the sequence order of the content that needs to be printed in the output. This option Adds custom HTML before (prepend) or after (append) the selected content or values. Thus jQuery.print is an essential plugin for a webpage, particularly where we wish to help users print a specific part