print-dom
v1.2.4
Published
Lightweight and fast print tool for browser.
Downloads
27
Maintainers
Readme
print-dom
Lightweight and fast print tool for browser.
Demo
Advantages
- Simple API.
- Small bundle size: 3.8KB (1.54KB gzipped).
- No dependencies.
- Faster than print-js
Installation
npm i print-dom -S
# OR
yarn add print-dom -S
Usage
import printDOM from "print-dom";
printDOM(document.querySelector("#print"));
with options
import printDOM from "print-dom";
printDOM(document.querySelector("#print"), {
noPrint: [".header"],
documentTitle: "Nice!!!",
wrapClass: ".print-wrapper",
style: ".print-wrapper { font-size: 16px; }",
});
Options
| Property | Description | Type | Default |
| :----------------- | :------------------------------------------- | :--------------------------------- | :------------------- |
| noPrint | Ignore list when printing. | String[]
| [".no-print"]
|
| documentTitle | Print page's title. | String
| Parent page's title. |
| style | Custom style. | String
| void
|
| wrapClass | Print element's className. | String
| void
|
| processor | Process the DOM before print. | (el: HTMLElement) => HTMLElement
| void
|
| onPrintDialogClose | Run when the browser print dialog is closed. | () => void
| void
|
Build
yarn build
Todo
- Add test files.
License
MIT © zh-rocco