Get started with print-js CDN

MIT licensed

Minimal library: Print-js generates print-ready CSS/HTML from an element.

Tags:
  • javascript
  • print.js
  • printjs

Stable version

Copied!

How to start using print-js CDN


<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css" />
    <script src="https://cdn.cdnhub.io/print-js/1.6.0/print.js"></script>
    <script src="script.js"></script>
</head>
<body>
    <button id="printBtn">Print this page</button>
    <div id="content">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque eget libero vel nibh elementum commodo.
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const printBtn = document.getElementById('printBtn');
            const content = document.getElementById('content');

            printBtn.addEventListener('click', function() {
                printJS({
                    printable: content,
                    type: 'css',
                    stylesheets: ['styles.css']
                });
            });
        });
    </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!

All versions