Easy to use, Element Printing Plugin for jQuery

Overview

jQuery Print Plugin

jQuery.print is a plugin for printing specific parts of a page

Usage

Include it in your HTML after importing jQuery, like:

	<script type="text/JavaScript" src="path/to/jquery.print.js"></script>

Use it like:

	$("#myElementId").print(/*options*/);

or

	$.print("#myElementId" /*, options*/);

You can submit the options object like:

	$("#myElementId").print({
        	globalStyles: true,
        	mediaPrint: false,
        	stylesheet: null,
        	noPrintSelector: ".no-print",
        	iframe: true,
        	append: null,
        	prepend: null,
        	manuallyCopyFormValues: true,
        	deferred: $.Deferred(),
        	timeout: 750,
        	title: null,
        	doctype: '<!doctype html>'
	});

Currently this plugin supports the following options:

globalStyles

  • Default: true
  • Acceptable-Values: Boolean
  • Function: Whether or not the styles from the parent document should be included

mediaPrint

  • Default: false
  • Acceptable-Values: Boolean
  • Function: Whether or not link tags with media='print' should be included; Over-riden by the globalStyles option

stylesheet

  • Default: null
  • Acceptable-Values: URL-string or Array of URL-strings
  • Function: URL of an external stylesheet to be included

noPrintSelector

  • Default: ".no-print"
  • Acceptable-Values: Any valid jQuery-selector
  • Function: A selector for the items that are to be excluded from printing

iframe

  • Default: true, creates a hidden iframe if no-vaild iframe selector is passed
  • Acceptable-Values: Any valid jQuery-selector or Boolean
  • Function: Whether to print from an iframe instead of a pop-up window; can take the jQuery-selector of an existing iframe as value

append/prepend

  • Default: null
  • Acceptable-Values: Any valid jQuery-selector or HTML-text
  • Function: Adds custom HTML before (prepend) or after (append) the selected content

manuallyCopyFormValues

  • Default: true
  • Acceptable-Values: Boolean
  • Function: Should it copy user-updated form input values onto the printed markup (this is done by manually iterating over each form element)

deferred

  • Default: $.Deferred()
  • Acceptable-Values: Any valid jQuery.Deferred object
  • Function: A jQuery.Deferred object that is resolved once the print function is called. Can be used to setup callbacks - see wiki

timeout

  • Default: 750
  • Acceptable-Values: Time in Milliseconds for setTimeout
  • Function: To change the amount of max time to wait for the content, etc to load before printing the element from the new window/iframe created, as a fallback if the load event for the new window/iframe has not fired yet

title

  • Default: null, uses the host page title
  • Acceptable-Values: Any single-line string
  • Function: To change the printed title

doctype

  • Default: '<!doctype html>'
  • Acceptable-Values: Any valid doctype string
  • Function: To prepend a doctype to the printed document frame

Tested with

jQuery

Browsers

  • Google Chrome - v 20, 26, 48, 55
  • Internet Explorer - v 10, 11
  • Firefox - v 35

License

CC-BY.

Demo

jQuery.print/demo

Comments
  • Sometimes the print preview appears blank

    Sometimes the print preview appears blank

    Trying to print a barcode with some Text values. But sometimes the print preview appears blank. Once I reload the page it works. Why is this happening? How to overcome this ?

    bug 
    opened by prem-kumar-e 11
  • Printing in firefox fails

    Printing in firefox fails

    Printing in firefox 37 does not work.

    Adding this code in the try-catch at line 132 makes it work again:

    var printed = w.document.execCommand('print', false, null); if (!printed) { w.print(); }

    bug invalid 
    opened by mduveborg-zz 11
  • Don't understand. can you help?

    Don't understand. can you help?

    Hello Print team,

    I copied and pasted the code below in a html5 page but nothing happens. What am I missing. We included the necessary script references. <div id="ele1" class="a"> <h3>Element 1</h3> <p> Some random text. </p> <button class="print-link no-print" onclick="jQuery('#ele1').print()"> Print this </button> </div> Kind regards, Mario

    question 
    opened by MarioVanDenEijnde 9
  • Won't get changed form values from textareas...

    Won't get changed form values from textareas...

    Hi, I have included this code on my page and it will print what is on the page wonderfully, with one exception: I have a couple of textareas on the page that I need to put text into and have that print with the page, but the values will not get printed. Whatever values those textareas hold at page load (one of them has default values) WILL print, but if I make any changes to the content of those textareas, those will NOT print, only the original copy will. I have checked that manuallyCopyFormValues is set to true, but no luck. Any ideas?

    bug 
    opened by ssuess 8
  • user selected (select/options) value not showing up in the print

    user selected (select/options) value not showing up in the print

    Expected behaviour

    Observed behaviour

    Steps to reproduce the issue

    Simplified demo link reproducing the issue

    jQuery, jQuery.print version

    Browser and operating system

    opened by drkrtj 7
  • Safari crashes when print dialog is cancelled and then  print is attempted again.

    Safari crashes when print dialog is cancelled and then print is attempted again.

    If I click a print button using the plugin (this happens on your example page as well), and then cancel the print job, When I click Print a second time, I get a dialog This webpage is trying to print. Do you want to print this webpage? Print or Cancel. Safari then crashes if I click Print rather than Cancel.

    wontfix 
    opened by macsupport 7
  • Blowing up after about 10 pages in IE11

    Blowing up after about 10 pages in IE11

    We are printing approx. 30 printed pages of HTML as PDF. It looks good until page 10, when we see the below and nothing else prints. On Chrome, with all the same code, it prints fine. FF also has a similar issue but sooner, at 3 pages. This is from Windows 7, jQuery 1.11, jQuery print 1.3.3. Any thoughts?

    ERROR: invalidaccess OFFENDING COMMAND: put STACK: /116 1 [/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand / quoteright /parenleft /parenright /asterisk

    bug question 
    opened by GregTVan 6
  • Printing a div with overflow-y: scroll

    Printing a div with overflow-y: scroll

    Expected behaviour

    Printing a DIV with an overflow, will print the whole DIV. Not only the visible text on the screen.

    Observed behaviour

    While printing, a part of the DIV will not be printed because it is not visible on the screen.

    Steps to reproduce the issue

    Create a DIV with the following styling. Create a text larger then the height of the DIV and print.

    height: 800px; max-height: 800px; overflow-x: hidden; overflow-y: scroll;

    Simplified demo link reproducing the issue

    none

    jQuery, jQuery.print version

    jQuery: v2.1.4 jQuery.print: v1.6.0

    Browser and operating system

    Chrome and Windows 10

    opened by RoelAlblas 5
  • Two instances of printer popup loading

    Two instances of printer popup loading

    Expected behaviour

    Observed behaviour

    Steps to reproduce the issue

    Simplified demo link reproducing the issue

    jQuery, jQuery.print version

    Browser and operating system

    opened by drkrtj 5
  • Plugin randomly failing in Iframe mode

    Plugin randomly failing in Iframe mode

    Hey guys, thank you for putting the plugin together. I have noticed both in development and in your own example page that when in iframe mode, the print screen will randomly be blank when printing. I was unable to track down what might be causing this. I am on Mac, El Capitan, Chrome v 48.0.2564.116.

    bug 
    opened by SethMusulin 5
  • Show Url in Printing

    Show Url in Printing

    Sir,

    Using jQuery.print.js When printing a table including link [ one colomn as <a href="..." type] , In printing time the corresponding url is displayed on printing page. I Want to avoid That Url.please help me

    question 
    opened by athenaneo 5
  • Add a footer with page number

    Add a footer with page number

    jQuery, jQuery.print version

    jQuery.print, version 1.6.2

    Browser and operating system

    Chromium

    Is it possible to add the page number in the footer of each page?

    opened by mathias22osterhagen22 0
  • Support for mobile devices

    Support for mobile devices

    Expected behaviour

    Printing same as on desktop device.

    Observed behaviour

    I test it on android chrome. And it would print the whole page.

    Steps to reproduce the issue

    Open chrome and test your script :)

    Browser and operating system

    android chrome

    bug Android 
    opened by Messa1 2
  • Does not install with composer when in Drupal project

    Does not install with composer when in Drupal project

    composer json file:

    "jqueryprint": {
                "type": "package",
                "package": {
                    "name": "DoersGuild/jQuery.print",
                    "version": "master",
                    "type": "drupal-library",
                    "source": {
                        "url": "https://github.com/DoersGuild/jQuery.print.git",
                        "type": "git",
                        "reference": "origin/master"
                    }
                }
            }
    

    getting error:

    - Installing doersguild/jquery.print (master origin/master): Failed to update https://github.com/DoersGuild/jQuery.print.git in cache, package installation for DoersGuild/jQuery.print might fail.
    Cloning origin/master from cache
    
    
      [RuntimeException]
      Failed to execute git checkout 'origin/master' -- && git reset --hard 'orig
      in/master' --
    
      fatal: failed to read object 422eb8fa91271724c19220c90a22b8a07ef687af: Oper
      ation not permitted
    
    
    opened by nasl 1
  • Plugin not workink on mobile environments

    Plugin not workink on mobile environments

    I've created this fiddle so you can check it out. Plugin is not workin on mobile environments.

    Tested with android six and latest Chrome and Firefox versions, also tested on iPhone 6.

    Chrome opens the whole page to be printed. Firefox does nothing. Safari opens new tab and automatically closes it.

    https://jsfiddle.net/pgioseffi/yLxbdgjr/

    bug Hacktoberfest iOS Android 
    opened by pgioseffi 3
  • Preview disappears after selecting printer

    Preview disappears after selecting printer

    When I click a link, the print dialog appears. It shows me preview of the page. But after selecting or changing printer, this preview disappears and showing only blank page. I use latest version of the script, 1.5.1. Iframe is on. Also tried the same action on you demo page - have the equivalent bug there. iphone 6s plus, 5s, ipad pro 12.9. ios 10.2.1

    bug Hacktoberfest iOS 
    opened by molfar 3
Releases(1.6.2)
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An easy-to-use jQuery plugin that allows the user to pick an icon from a responsive icon browser and shows the corresponding icon class in an input element.

Font Awesome Browser An easy-to-use jQuery plugin that allows the user to pick an icon from a responsive icon browser and shows the corresponding icon

Gianluca Chiarani 1 May 1, 2021
CLI tool for printing anime quotes in your terminal.

aniquote Why? While i was browsing Unixporn looking to steal someone's dotfiles (im too lazy to rice myself) i saw some anime-related rices and though

kugi 14 Dec 22, 2022
An easy to implement marquee JQuery plugin with pause on hover support. I know its easy because even I can use it.

Simple-Marquee Copyright (C) 2016 Fabian Valle An easy to implement marquee plugin. I know its easy because even I can use it. Forked from: https://gi

null 16 Aug 29, 2022
jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested on Firefox/Chrome/Maxthon/iPhone/Android. Very light <7ko min.js and <1Ko min.css.

Nice-Scrollbar Responsive jQuery based scrolling Bar, for PC and Smartphones (touch events). It is modern slim, easy to integrate, easy to use. Tested

Renan LAVAREC 2 Jan 18, 2022
JavaScript micro-library: pass in an element and a callback and this will trigger when you click anywhere other than the element

Add a click listener to fire a callback for everywhere on the window except your chosen element. Installation run npm install @lukeboyle/when-clicked-

Boyleing Point 5 May 13, 2021
A jQuery plugin allowing you to scroll an image within a container element

jQuery Scroll Image Inside v0.1 A jQuery plugin allowing you to scroll an image within a container element Usage <div id="window"> <img src="reall

Derek Ashauer 1 Apr 11, 2021
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
A simple jQuery extension to make any HTML element sticky on scroll.

jquery.sticky.js A simple jQuery extension to make any HTML element sticky on scroll. Installation Just download the script and include it in your HTM

Achal Jain 2 Aug 22, 2022
A jQuery plug-in to notify you of CSS, Attribute or Property changes in an element

selectWatch.js jQuery plug-in gives an opportunity to monitor changes of DOM element's CSS styles, attributes, properties, input element or select ele

Fatih Kazancı 3 Oct 28, 2022
A simple lightweight file dropzone component based on jQuery. You can easily make any existing element become a dropzone that holds files.

file-dropzone A simple lightweight file dropzone component based on jQuery. You can easily make any existing element become a dropzone that holds file

Anton Bardov 1 May 31, 2021
Creates a table of contents in a DOM element optionally linked to with anchors. No jQuery or other dependencies.

HTML-Contents Creates a table of contents in a DOM element optionally linked to with anchors. No dependencies. @psalmody Get It We're on npm: npm i ht

Michael Tallino 3 Oct 25, 2022
adds the *scrollin* and *scrollout* events to jquery, which will fire when any given element becomes (respectively) visible and invisible in the browser viewpori

jQuery.scrolling This plugin adds the scrollin and scrollout events to jquery: these events will fire when any given element becomes visible/invisible

Dark 5 Apr 7, 2021
Create sticky element in flexbox sidebars. it can use in Vanilla JS and frameworks like Vue and React

js sticky side simple sticky side with js that can use in frameworks like vue and react. notes it can be used just in flexbox grids. target element sh

milad nazari 10 Mar 3, 2022
Easy responsive tabs - is a lightweight jQuery plugin which optimizes normal horizontal or vertical tabs to accordion on multi devices

Easy responsive tabs - is a lightweight jQuery plugin which optimizes normal horizontal or vertical tabs to accordion on multi devices like: web, tablets, Mobile (IPad & IPhone). This plugin adapts the screen size and changes its action accordingly.

Samson Onna 600 Dec 8, 2022
jQuery easy ticker is a news ticker like plugin, which scrolls the list infinitely. It is highly customizable, flexible with lot of features and works in all browsers.

jQuery Easy Ticker plugin jQuery easy ticker is a news ticker like plugin which scrolls a list infinitely. It is highly customizable, flexible with lo

Aakash Chakravarthy 208 Dec 20, 2022
Jquery Plugin for Make easy Toast

Nice Toast JS nice and easy toast for jquery Requirements jQuery Installation NPM npm install nice-toast-js Yarn yarn add nice-toast-js CDN - jsDelivr

Hasan Ahani 4 Jul 26, 2022