Customizable Multiple Elements Printing Plugin With jQuery - printThis

Customizable Multiple Elements Printing Plugin With jQuery - printThis
File Size: 11.8 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Yet another page printing plugin for jQuery that allows the user to print specific element(s) of your webpage, while preserving the page styles (and even additional CSS) and input/form values.

More features:

  • Auto removes inline styles.
  • Print delay supported.
  • Custom header and page title.

Installation:

# NPM
$ npm install print-this

# Bower
$ bower install print-this

How to use it:

1. Place both jQuery library and the jQuery printThis plugin's script right before the closing body tag:

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="printThis.js"></script>

2. Attach the function printThis on any element(s) you want to print.

$('form,h1,p').printThis();

3. Possible options to customize the printing plugin.

$('SELECTORS').printThis({

  // shows debug info
  debug: false,

  // import page CSS
  importCSS: true,

  // import styles
  importStyle: false,

  // print outer container
  printContainer: true, 

  // additonal CSS file
  loadCSS: "", 

  // page title
  pageTitle: "",

  // remove inline styles
  removeInline: false, 

  // print delay in ms
  printDelay: 333,

  // header 
  header: null,

  // footer
  footer: null,    

  // preserve input/form values
  formValues: true, 

  // preserve the base tag (if available)
  base: false,

  // html doctype
  doctypeString: '<!DOCTYPE html>', 

  // remove script tags before appending
  removeScripts: false    
  
});

Change logs:

2017-04-10

  • V1.10.0 - Added action, disabled by default, to avoid bringing unwanted scripts into the print iframe; Removed undocumented helper function $.fn.outer.

2017-03-07

  • V1.9.0 - Canvas updates

2017-01-17

  • V1.9.0 - Canvas updates

2017-01-17

  • V1.8.0 - Added "footers"

2016-12-15

  • Add base URL support and increment version

This awesome jQuery plugin is developed by jasonday. For more Advanced Usages, please check the demo page or visit the official website.