whatisgithub

What is print.js?

crabbly/print.js — explained in plain English

Analysis updated 2026-06-26

4,553JavaScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A small JavaScript library that lets you print just a specific part of a web page, such as a PDF, image, HTML form, or page section, instead of printing the entire page.

Mindmap

mindmap
  root((print.js))
    What it does
      Targeted printing
      No full-page print
      Single function call
    Supported targets
      HTML elements
      PDF files
      Images
      Forms
    Setup
      npm or yarn install
      Import one line
    Testing
      Jasmine tests
      Karma runner
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add a print button that sends only an invoice or receipt section of a page to the printer

USE CASE 2

Let users print a completed HTML form without the surrounding navigation and page layout

USE CASE 3

Trigger a print dialog for a specific PDF displayed inside a web application

USE CASE 4

Print a single product image from a page without extra content

What is it built with?

JavaScript

How does it compare?

crabbly/print.jsmermaid-js/mermaid-cliapostrophecms/apostrophe
Stars4,5534,5514,556
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyeasymoderate
Complexity2/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
MIT License, use freely in any personal or commercial project without restriction.

So what is it?

Print.js is a small JavaScript library that makes it easier to trigger print dialogs from a web page. Instead of printing the entire page, it lets you target specific things, like a PDF file, an HTML form, an image, or a section of the page, and send just that to the printer. The goal is to keep the library lightweight and focused on one job. To add it to a project, you install it through npm or yarn, two common tools developers use to manage JavaScript code packages. You import it into your code with one line, and from there you call it whenever you want to offer a print action. Full usage examples and configuration options live on the project's external documentation site at printjs.crabbly.com rather than in this repository. The README is intentionally sparse. It covers installation steps, points to the documentation website for actual usage, and explains how contributors can report bugs or submit improvements. Bug reports should include a reproducible example, and the maintainers prefer keeping the library small rather than adding many new features. For developers who want to work on the library itself, the process is to install dependencies with npm, run a watch command during development, and use the built-in test suite to check for problems. Tests are written with Jasmine, a JavaScript testing framework, and run through Karma, a test runner. The code follows the JavaScript Standard style guide, so style issues are caught alongside logic errors during testing. The project is MIT licensed, which means it is free to use in personal and commercial projects without restriction.

Copy-paste prompts

Prompt 1
Using Print.js, add a print button to my invoice page that prints only the div with id 'invoice' and not the rest of the navigation or header.
Prompt 2
My web app shows a multi-page PDF in an iframe. How do I use Print.js to let users print just that PDF from a button click?
Prompt 3
Show me how to install Print.js with npm and wire it up so clicking a button triggers printing a specific HTML form.
Prompt 4
I want to print an image from my gallery page using Print.js. Walk me through the setup and the exact function call needed.

Frequently asked questions

What is print.js?

A small JavaScript library that lets you print just a specific part of a web page, such as a PDF, image, HTML form, or page section, instead of printing the entire page.

What language is print.js written in?

Mainly JavaScript. The stack also includes JavaScript.

What license does print.js use?

MIT License, use freely in any personal or commercial project without restriction.

How hard is print.js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is print.js for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.