jQuery Printing Plugin

January 04, 2020 No comments jQuery Plugin Printing GitHub

1. Introduction

PrintThis is a great jQuery printing plugin that allows you to apply a printing page or a part of a page functionality on your website/application. The plugin can print one chosen DOM element or many of them at once. Printing canvas is also supported. PrintThis plugin lets you disable CSS styles and JavaScript scripts before printing the page.

Query printing plugin

2. Plugin Overview

Library PrintThis
Author Jason Day and Samuel Rouse
Licence MIT Licence
Repository GitHub
Dependencies jQuery 1.3.1

Demo

3. How to install and use PrintThis jQuery plugin

The below section will give you instructions on how to install PrintThis plugin step by step.

1. load jQuery library and PrintThis JavaScript file

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<!-- PrintThis Js -->
<script type="text/javascript" src="printThis.js"></script>

2. for specific DOM element that you want to print add unique id

<p id="toPrint">Bathe self with tongue then lick owner's face kitten is playing with dead mouse and leave dead animals as gifts.
          Lies down . Ears back wide eyed then cats take over the world meowing non stop for food.</p>

3. initialize PrintThis plugin with that id selector in jQuery document ready function

$(document).ready(function(){
   $("#toPrint").printThis();
});

PrintThis will print selected DOM element in the best quality it can.

4. Conclusion

In this article, we presented a jQuery plugin PrintThis designed for printing the whole page or just selected DOM elements. PrintThis supports printing images, plain text, canvas, div and many more. You can also disable JavaScript scripts.

{{ message }}

{{ 'Comments are closed.' | trans }}