Printing plug-in for jQuery
- Print specific & multiple DOM elements
- Preserve page CSS/styling ** or add new CSS; the world is your oyster!
- Preserve form entries
- Canvas support
Covers common issues related to styling and printing limitations regarding page breaks
Now with TypeScript definitions.
Debug leaves the iframe visible on the page after
printThis runs, allowing you to inspect the markup and CSS.
<link> tags to the printThis iframe. On by default.
<style> tags to the printThis iframe. Off by default.
Includes the markup of the selected container, not just its contents. On by default.
Provide a URL for an additional stylesheet to the printThis iframe. Empty string (off) by default.
Use a custom page title on the iframe. This may be reflected on the printed page, depending on settings. Blank by default.
Eliminates any inline style attributes from the content. Off by default.
Filter which inline style attributes to remove. Requires
removeInline to be true.
Accepts custom CSS/jQuery selectors. Default is
The amount of time to wait before calling
print() in the printThis iframe. Defaults to 333 milliseconds.
Appropriate values depend heavily on the content and network performance. Graphics heavy, slow, or uncached content may need extra time to load.
header & footer
A string or jQuery object to prepend or append to the printThis iframe content.
null by default.
As of 1.9.1, jQuery objects are cloned rather than moved.
base option allows several behaviors.
By default it is
false, meaning a the current document will be set as the base URL.
If set to
<base> attribute will be set if one exists on the page.
If none is found, the tag is omitted, which may be suitable for pages with Fully Qualified URLs.
When passed as a string, it will be used as the
href attribute of a
This setting copies the current values of form elements into the printThis iframe. On by default.
As of 1.9.0 you may be able to duplicate canvas elements to the printThis iframe. Disabled by default. This has received only limited testing and so may not work in all browsers and situations.
As of 1.12.2 you can call printThis directly on a canvas element.
A doctype string to use on the printThis iframe. Defaults to the HTML5 doctype.
Deletes script tags from the content to avoid errors or unexpected behavior during print. Disabled by default.
Copies classes from the body and html tags into the printThis iframe.
true or test for the strings
"h" for the body and html tags, respectively.
Disabled by default.
Function to run inside the iframe before the print occurs.
This function has not been validated on all browsers.
Function called before the iframe is populated with content.
Function called after the print and before the iframe is removed from the page.
This is called even if
debug: true, which does not remove the iframe.
- "It's not working" without any details is not a valid issue and will be closed
- A url, or html file, is necessary to debug. Due to the complexities of printing and this plugin, an example is the best way to debug
- When troubleshooting, set
debug: trueand inspect the iframe. Please report your findings when reporting an issue
- Every user should be active in the debugging process
- Look at alternative to setTimeout ($.deferred?)
This project exists thanks to all the people who contribute. [Contribute].
Become a financial contributor and help us sustain our community. [Contribute]
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]