Print Specific Part of Web Page – printElements.js

Category: Javascript | April 14, 2024
Author:luxonauta
Views Total:32 views
Official Page:Go to website
Last Update:April 14, 2024
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"
});

Changelog:

04/14/2024

  • Improve error messages

You Might Be Interested In:


Leave a Reply