light-print
v2.0.6
Published
A lightweight print tool for the browser
Downloads
5
Readme
light-print
A lightweight print tool for the browser.
Install
npm install --save light-print
# or
yarn add light-print
# or
pnpm add light-print
Usage
Print container elements and their descendants.
import lightPrint from 'light-print';
lightPrint('#id', { mediaPrintStyle: `@page { size: A4 portrait }` }).then(() => {
// do something when exiting the print window.
});
- The argument can either be a CSS selector or an actual DOM element.
- Returns a Promise when exiting the print window.
Types
interface PrintOptions {
/** document title */
documentTitle?: string;
/** additional print style when printing */
mediaPrintStyle?: string;
/** page zoom */
zoom?: number | string;
}
function lightPrint(containerOrSelector: Element | string, options?: PrintOptions): Promise<void>;