A lightweight print tool for the browser.
npm install --save light-print
# or
yarn add light-print
# or
pnpm add light-print
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.
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>;