a mini tool for print html page with browser.
You can download the latest version of print_html_js.js from the GitHub releases or use the npm.
To install via npm:
npm install print_html_js --save
yarn add print_html_js
When installing via npm or yarn, import the library into your project:
import print from 'print_html_js'
<html>
<body>
<div id="print">print this</div>
<script src="https://unpkg.com/print_html_js@0.0.1/dist/print_html.min.js"></script>
<script>
// const print = document.querySelector('#print');
// const printHtml = new printHtml(print);
// or
const printHtml = new PrintHtml('#print'); // you can add options: {dev: true} enable print css debugger
printHtml.print();
</script>
</body>
</html>
accept two arguments elementOrSelector and options
arguments | type | default |
---|---|---|
dom | elementOrSelector | - |
arguments | type | default |
---|---|---|
dev | Boolean | false |
style | string | '' |
printFrameId | string | 'print-html-id' |
Please make sure printFrameId only one in this page
Chrome | Firefox | IE | Edge | Safari