{"id":16092488,"url":"https://github.com/luxonauta/printelements","last_synced_at":"2025-03-17T17:31:04.291Z","repository":{"id":50978080,"uuid":"272804294","full_name":"luxonauta/printElements","owner":"luxonauta","description":"🖨️ A JavaScript library to easily print content from web pages.","archived":false,"fork":false,"pushed_at":"2024-04-15T02:05:08.000Z","size":117,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-02T05:01:12.444Z","etag":null,"topics":["html","pdf","print"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luxonauta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-16T20:20:14.000Z","updated_at":"2024-04-15T02:06:36.000Z","dependencies_parsed_at":"2024-04-15T02:30:59.457Z","dependency_job_id":"3dab01e1-1672-4c11-8887-b5a364d130c1","html_url":"https://github.com/luxonauta/printElements","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxonauta%2FprintElements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxonauta%2FprintElements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxonauta%2FprintElements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luxonauta%2FprintElements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luxonauta","download_url":"https://codeload.github.com/luxonauta/printElements/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871911,"owners_count":20361380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","pdf","print"],"created_at":"2024-10-09T16:08:48.103Z","updated_at":"2025-03-17T17:31:04.076Z","avatar_url":"https://github.com/luxonauta.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# printElements\n\n\u003e A JavaScript library to easily print content from web pages.\n\n## Motivation\n\nCreating a print-ready PDF from web content can be tricky and time-consuming. This library simplifies the process, allowing you to print only the content you need with minimal fuss.\n\n## Features\n\n- Select specific HTML tags within a specified container for printing;\n- Exclude elements with a designated class from the print output;\n- Handles dynamic DOM environments by ensuring the print operation is only executed when the DOM is fully accessible;\n- Provides flexibility with configurable delay options to manage different rendering times.\n\n## Quick Start\n\n### Via CDN\n\n```html\n\u003clink\n  rel=\"stylesheet\"\n  href=\"https://cdn.jsdelivr.net/gh/luxonauta/printElements@latest/dist/printElements.min.css\"\n/\u003e\n\n\u003cscript\n  src=\"https://cdn.jsdelivr.net/gh/luxonauta/printElements@latest/dist/printElements.min.js\"\n  crossorigin=\"anonymous\"\n/\u003e\n```\n\nOr download it directly from the [GitHub repository](https://github.com/luxonauta/printElements/tree/main/dist).\n\n## Usage\n\nWrap the content to be printed within a `\u003cmain\u003e` tag. Then call `printElements(options)` with your specified options:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003clink rel=\"stylesheet\" href=\"path/to/printElements.min.css\" /\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cmain\u003e\n      \u003ch1\u003eYour Content Here\u003c/h1\u003e\n      \u003c!-- Additional content --\u003e\n    \u003c/main\u003e\n    \u003cbutton id=\"printBtn\"\u003ePrint\u003c/button\u003e\n    \u003cscript src=\"path/to/printElements.min.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003e\n      document.addEventListener(\"DOMContentLoaded\", () =\u003e {\n        const printOptions = {\n          targets: [\"index.html\"],\n          tags: [\"h1\", \"p\", \"li\"],\n          willNotPrint: \"exclude\",\n          wrapper: \"main\",\n          delay: 150 // Optional delay in milliseconds before printing\n        };\n\n        document.getElementById(\"printBtn\").onclick = () =\u003e\n          printElements(printOptions);\n      });\n    \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n- `wrapper`: Specify the container element whose contents you want to print (default is `\"main\"`);\n- `willNotPrint`: Apply the class `\"exclude\"` to any HTML element within the wrapper to prevent it from being printed;\n- `delay`: Customize the delay in milliseconds before the print command is executed, to ensure all content is rendered properly.\n\n### License\n\nReleased under the [MIT License](/license.md). You are free to use and modify it for your projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxonauta%2Fprintelements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluxonauta%2Fprintelements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxonauta%2Fprintelements/lists"}