Nine Parsecs from Milwaukee

    print-dom
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.4 • Public • Published

    print-dom

    Lightweight and fast print tool for browser.

    downloads GitHub stars devDependencies npm-version Github tag Build Status GitHub license

    Demo

    Try it out

    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

    Install

    npm i print-dom

    DownloadsWeekly Downloads

    57

    Version

    1.2.4

    License

    MIT

    Unpacked Size

    9.26 kB

    Total Files

    5

    Last publish

    Collaborators

    • dahann