{"id":42206245,"url":"https://github.com/dantio/html2pdfmake","last_synced_at":"2026-01-27T00:34:39.077Z","repository":{"id":57686749,"uuid":"477068588","full_name":"dantio/html2pdfmake","owner":"dantio","description":"html2pdfmake parse html to content that can be used in pdfmake.","archived":false,"fork":false,"pushed_at":"2022-06-30T16:20:22.000Z","size":1235,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-29T04:48:22.317Z","etag":null,"topics":["pdf","pdfmake","pdfmake-library"],"latest_commit_sha":null,"homepage":"https://dantio.github.io/html2pdfmake/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dantio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-02T13:51:40.000Z","updated_at":"2024-10-24T08:18:01.000Z","dependencies_parsed_at":"2022-09-19T08:25:00.212Z","dependency_job_id":null,"html_url":"https://github.com/dantio/html2pdfmake","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/dantio/html2pdfmake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantio%2Fhtml2pdfmake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantio%2Fhtml2pdfmake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantio%2Fhtml2pdfmake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantio%2Fhtml2pdfmake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantio","download_url":"https://codeload.github.com/dantio/html2pdfmake/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantio%2Fhtml2pdfmake/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28793507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:49:50.245Z","status":"ssl_error","status_checked_at":"2026-01-26T21:48:29.455Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["pdf","pdfmake","pdfmake-library"],"created_at":"2026-01-27T00:34:38.471Z","updated_at":"2026-01-27T00:34:39.070Z","avatar_url":"https://github.com/dantio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# html2pdfmake\nAdvanced HTML to PDFMake DocDefinition parser.\n\nParse HTML/DOM to pdfmake.\n\n## Install\n```bash \nnpm i html2pdfmake\nyarn add html2pdfmake\n```\n\n## Quick Usage\n### Module\n```html\n\u003cdiv id=\"template\"\u003e\n    \u003cp\u003eText\u003c/p\u003e\n\u003c/div\u003e\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.3.0-beta.2/pdfmake.min.js\"\u003e\u003c/script\u003e\n\u003cscript type=\"module\"\u003e\nimport {parse} from 'https://cdn.jsdelivr.net/npm/html2pdfmake/dist/html2pdfmake.mjs';\nconst {content, images, patterns} = parse(document.getElementById('template'));\n\npdfMake.createPdf({\n  // everything else\n  content,\n  images,\n  patterns\n})\n\u003c/script\u003e\n```\n\n### UMD\n```html\n\u003cdiv id=\"template\"\u003e\n    \u003cp\u003eText\u003c/p\u003e\n\u003c/div\u003e\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.3.0-beta.2/pdfmake.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/html2pdfmake/lib/html2pdfmake.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\nconst {content, images, patterns} = html2pdfmake.parse(document.getElementById('template'));\npdfMake.createPdf({\n  // everything else\n  content,\n  images,\n  patterns\n})\n\u003c/script\u003e\n```\n\n## Config\nPass the config as the second parameter in `parse` function.\n```ts\n// parse('\u003cdiv\u003e\u003c/div\u003e', config);\nexport type Config = {\n  globalStyles?: CssStyles, // custom global styles\n  styles: CssStyles, // additional styles merged that overwrites globals styles\n  nodeRule?: NodeRule // set the custom node rule. Return undefined if pre-defined rules should be applied.\n  styleRule?: StyleRule // set the custom style rule. Return false if pre-defined rules should be applied.\n  collapseMargin: true, // Enable/Disable margin collapse\n  collapseWhitespace: true, // Enable/Disable witespace collapse\n  render: (e, data) =\u003e e, // set render function for header/footer\n  document: () =\u003e window.document, // set the global document object\n  parseCss: (style: NodeListOf\u003cHTMLStyleElement\u003e) =\u003e {}, // define \u003cstyle\u003e parser\n  defaultFont: 'Roboto', // set the default font\n  fonts?: TFontDictionary // pass the fonts that you are using for pdfmake to filter unsupported fonts.\n}\n```\n\n### nodeRule example\n```js\nconst config = {\n  nodeRule: (el) =\u003e {\n    if (el.nodeName === '#text') {\n      return {\n        text: 'My Custom text'\n      };\n    }\n\n    return undefined; // use pre-defined rules\n  }\n}\n```\n\n### styleRule example\n```js\nconst config = {\n  styleRule: (directive, value, props) =\u003e {\n    if (directive === 'color') {\n      props.color = 'red';\n      return true; // \n    }\n\n    return false;\n  }\n}\n```\n\n\n### NodeJS\nInstall a HTML parser like JSDOM. \n\n## Run examples\n```sh\nnpm i http-server -g\nnpm i\nnpm run watch\n# open new terminal\nhttp-server .\n# open localhost:8080\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantio%2Fhtml2pdfmake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantio%2Fhtml2pdfmake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantio%2Fhtml2pdfmake/lists"}