{"id":13837129,"url":"https://github.com/rpdasilva/print-html-element","last_synced_at":"2025-10-22T14:37:07.041Z","repository":{"id":57330505,"uuid":"37475759","full_name":"rpdasilva/print-html-element","owner":"rpdasilva","description":"Prints the HTML of a provided element.","archived":false,"fork":false,"pushed_at":"2019-01-16T08:57:47.000Z","size":42,"stargazers_count":24,"open_issues_count":8,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T16:58:41.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rpdasilva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-15T16:04:18.000Z","updated_at":"2022-09-07T06:28:54.000Z","dependencies_parsed_at":"2022-08-31T00:01:12.767Z","dependency_job_id":null,"html_url":"https://github.com/rpdasilva/print-html-element","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpdasilva%2Fprint-html-element","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpdasilva%2Fprint-html-element/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpdasilva%2Fprint-html-element/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpdasilva%2Fprint-html-element/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rpdasilva","download_url":"https://codeload.github.com/rpdasilva/print-html-element/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225648314,"owners_count":17502174,"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":[],"created_at":"2024-08-04T15:01:01.556Z","updated_at":"2025-10-22T14:37:02.002Z","avatar_url":"https://github.com/rpdasilva.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Print HTML Element\n\nPrints the HTML of a provided element.\n\nOriginally forked from [jQuery.printElement](https://github.com/erikzaadi/jQueryPlugins/tree/master/jQuery.printElement) to remove jQuery dependency.\n\nThis fork removes some features while adding others (IE8 support is also removed for now). More features will be added as needed or requested.\nPR's welcome.\n\nView examples [here](https://rpdasilva.github.io/print-html-element/)\n\n## Installation\nPrint HTML Element is available on both NPM and Bower.\n\n`npm install print-html-element`\n\n`bower install print-html-element`\n\n\n## Usage\n\n\n### Include\nIn a CommonJS module system via Browserify or Webpack\n```js\n    var PHE = require(\"print-html-element\");\n```\n\nGood old-fashioned way\n```html\n    \u003cscript type=\"text/javascript\" src=\"print-html-element.js\"\u003e\u003c/script\u003e\n```\n```js\n    // Alias global variable printHtmlElement for purposes of example\n    var PHE = printHtmlElement;\n```\n\n### Examples\nView examples [here](https://rpdasilva.github.io/print-html-element/)\n\n```js\n    PHE.printElement( document.getElementById('toPrint') );\n    PHE.printHtml('\u003ch1\u003eLet\\'s print this h1\u003c/h1\u003e');\n\n    PHE.printHtml('\u003ch1\u003eLet\\'s print this h1\u003c/h1\u003e', {templateString: '\u003cheader\u003eI\\'m part of the template header\u003c/header\u003e{{printBody}}\u003cfooter\u003eI\\'m part of the template footer\u003c/footer\u003e'});\n```\n\nAn HTML class `pe-body` is also added to the body of the print area which can be used as an additional style hook (on top of the regular print media query/stylesheet)\n\n### Options and methods supported\n```js\n    opts = {\n        printMode: string;\n        pageTitle: string;\n        templateString: string;\n        popupProperties: string;\n        stylesheets: string | string[];\n        styles: string | string[];\n    };\n\n    PHE.printElement( elem, opts ); // Prints a DOM Element\n    PHE.printHtml( str, opts ); // Prints an HTML string\n```\n\n- printMode determines which method is used to print. As a hidden `iframe` (default), or `popup` window\n- pageTitle sets the printed page title (defaults to blank)\n- templateString allows you to define a template that the html will be printed within.\n    - Use `{{printBody}}` within the template to signify where the HTML should be injected\n- popupProperties set the window features (such as `menubar`, `scrollbars`, etc. in `popup` mode\n- stylesheets overrides parsed `link` tags and instead injects `link` tags with hrefs specified as either a single string or array of strings\n- styles overrides parsed `style` tags and instead injects `style` blocks specified as either a single string or array of strings\n\n\n## Possible future features\n\n- Integrate a template system (such as handlebars)\n- Support multiple and/or custom template variables\n- Support for multiple elements/HTML strings\n- Promise/callback support\n\n\n## License\n\n`print-html-element` is [MIT licensed](LICENSE.txt)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpdasilva%2Fprint-html-element","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frpdasilva%2Fprint-html-element","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpdasilva%2Fprint-html-element/lists"}