Print Specific Part of Web Page – printElements.js

Category: Javascript | March 24, 2023
Author:luxonauta
Views Total:157 views
Official Page:Go to website
Last Update:March 24, 2023
License:MIT

Preview:

Print Specific Part of Web Page – printElements.js

Description:

Just another JavaScript printing plugin that allows the user to print only a specific part of the web page. This can help reduce paper waste, save ink, and improve the overall printing experience.

How to use it:

1. Load the stylesheet printElements.min.css and JavaScript printElements.min.js in the document.

<link rel="stylesheet" href="dist/printElements.min.css" />
<script src="dist/printElements.min.js"></script>

2. Initialize the plugin and specify an array of the HTML tags to be printed.

printElements({
  "tags": [
    "h1",
    "h2",
    "h3",
    // ...
  ],
});

3. Specify the path to the HTML page to be printed.

printElements({
  "tags": [
    "h1",
    "h2",
    "h3",
    // ...
  ],
  "targets": [
    "doc.html",
  ],
});

4. Specify the CSS selector of ignored elements.

printElements({
  "tags": [
    "h1",
    "h2",
    "h3",
    // ...
  ],
  "targets": [
    "doc.html",
  ],
  "willNotPrint": "ignore"
});

You Might Be Interested In:


Leave a Reply