Press "Enter" to skip to content

A Simple Webpage Printing library In Pure JavaScript | Print.js

Print.js is primarily written to help us print PDF files directly within our applications, without leaving the interface, and not using embeds. In the unique cases where users do not need to open or download PDF files, instead, they just need to print them.

Print JS is a pure JavaScript library that helps you print any parts (pdfs, photos, HTML parts, or JSON information objects) from your webpages & information.

javascript print directly to default printer, print js pdf example, print js example, javascript print div, print js with css, print js github

How to make use of it:

Install it by way of NPM:

$ npm install print.js

Import the print.js into your web challenge or immediately include the JavaScript file onto your webpage.

<script src="print.js"></script>

Print a file that’s saved in your web server.


A print specific part of your webpage.

<div id="printJS-html">
printJS('printJS-html', 'html')

Print a picture from your webpage.

printJS('image.jpg', 'image');

All attainable configuration options.

  printable: null, // Document source: pdf or image url, html element id or json data object.
  type: 'pdf', // 'pdf', 'html', 'image', 'raw-html', and 'json'
  header: null, // header content
  maxWidth: 800,
  font: 'TimesNewRoman',
  font_size: '12pt',
  honorMarginPadding: true,
  honorColor: false,
  properties: null, // Used when printing JSON. These are the object property names.
  showModal: false,
  modalMessage: 'Retrieving Document...',
  frameId: 'printJS',
  border: true,
  htmlData: ''

Custom Webpage Printing library In Pure JavaScript, How to print HTML content, Print.js Github

See Demo And Download

Official Website(crabbly): Click Here

This superior jQuery/javascript plugin is developed by crabbly. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.