{"id":20955104,"url":"https://github.com/myunisoft/html-pdf","last_synced_at":"2025-05-14T04:33:02.918Z","repository":{"id":38301999,"uuid":"438077924","full_name":"MyUnisoft/HTML-PDF","owner":"MyUnisoft","description":"Node lib to converts HTML with property binding or url to PDF files.","archived":false,"fork":false,"pushed_at":"2024-02-29T23:47:45.000Z","size":534,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-02T13:03:21.199Z","etag":null,"topics":["browser","nodejs","pdf","puppeteer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/MyUnisoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-12-14T01:27:47.000Z","updated_at":"2023-11-25T02:48:29.000Z","dependencies_parsed_at":"2023-11-27T14:59:49.362Z","dependency_job_id":null,"html_url":"https://github.com/MyUnisoft/HTML-PDF","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyUnisoft%2FHTML-PDF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyUnisoft%2FHTML-PDF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyUnisoft%2FHTML-PDF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MyUnisoft%2FHTML-PDF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MyUnisoft","download_url":"https://codeload.github.com/MyUnisoft/HTML-PDF/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254071365,"owners_count":22009779,"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":["browser","nodejs","pdf","puppeteer"],"created_at":"2024-11-19T01:18:00.763Z","updated_at":"2025-05-14T04:33:02.559Z","avatar_url":"https://github.com/MyUnisoft.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003ch1 align=\"center\"\u003e\n  HTML-PDF\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  Node lib to converts HTML with property binding or url to PDF files.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF\"\u003e\u003cimg src=\"https://img.shields.io/github/package-json/v/MyUnisoft/HTML-PDF?style=flat-square\" alt=\"npm version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF\"\u003e\u003cimg src=\"https://img.shields.io/github/license/MyUnisoft/HTML-PDF?style=flat-square\" alt=\"license\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF\"\u003e\u003cimg src=\"https://img.shields.io/github/languages/code-size/MyUnisoft/HTML-PDF?style=flat-square\" alt=\"size\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 🚧 Requirements\n\n- [Node.js](https://nodejs.org/en/) version 14 or higher\n\n## 🚀 Getting Started\n\nThis package is available in the Node Package Repository and can be easily installed with [npm](https://doc.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com)\n\n```bash\n$ npm i @myunisoft/html-to-pdf\n# or\n$ yarn add @myunisoft/html-to-pdf\n```\n\n## 📚 Usage\n\n```js\nasync function main() {\n  const browser = await initBrowser();\n  let readable;\n\n  try {\n    readable = Readable.from(generatePDF(browser, [{ content: html }], pdfOptions));\n  }\n  finally {\n    await terminateBrowser(browser);\n  }\n\n  return readable;\n}\n\nmain().catch(console.error);\n```\n\n## API\n\n\u003cdetails\u003e\n\u003csummary\u003einitBrowser(options?: PuppeteerLaunchOptions): Promise\u003c Browser \u003e\u003c/summary\u003e\n\n```js\nimport { initBrowser } from \"@myunisoft/html-to-pdf\";\n\nconst browser = await initBrowser();\n```\n\nOptions payload is described by the following TypeScript interface:\n```ts\nimport {\n  LaunchOptions,\n  BrowserLaunchArgumentOptions,\n  BrowserConnectOptions,\n  Product\n} from \"puppeteer\";\n\ntype PuppeteerLaunchOptions = LaunchOptions \u0026 BrowserLaunchArgumentOptions \u0026 BrowserConnectOptions \u0026 {\n    product?: Product;\n    extraPrefsFirefox?: Record\u003cstring, unknown\u003e;\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003egeneratePDF(browser: Browser, files: pdfFile[], options?: PuppeteerPDFOptions): AsyncIterableIterator\u003c Buffer \u003e\u003c/summary\u003e\n\n`files` and `options` arguments are described with the following TypeScript interface/type:\n```ts\ninterface pdfFile {\n  content?: string,\n  url?: string\n}\n\ntype PuppeteerPDFOptions = PDFOptions \u0026 { paginationOffset?: number };\n```\n\n```js\nimport * as pdf from \"@myunisoft/html-to-pdf\";\n\nconst browser = await pdf.initBrowser();\n\nconst pdfOptions = {};\nconst content = \"..HTML HERE..\";\n\nconst readable = Readable.from(\n  pdf.generatePDF(browser, [{ content }], pdfOptions)\n);\n// Do the work with readable (pipe to an http response for example).\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eterminateBrowser(browser: Browser): Promise\u003c void \u003e\u003c/summary\u003e\n\n```js\nimport * as pdf from \"@myunisoft/html-to-pdf\";\n\nconst browser = await pdf.initBrowser();\n\ntry {\n  // DO THE WORK HERE\n}\nfinally {\n  await pdf.terminateBrowser(browser);\n}\n```\n\n\u003c/details\u003e\n\n## Contributors ✨\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://www.linkedin.com/in/nicolas-hallaert/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/39910164?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eNicolas Hallaert\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/MyUnisoft/HTML-PDF/commits?author=Rossb0b\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF/commits?author=Rossb0b\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF/commits?author=Rossb0b\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://www.linkedin.com/in/thomas-gentilhomme/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4438263?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eGentilhomme\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#security-fraxken\" title=\"Security\"\u003e🛡️\u003c/a\u003e \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF/pulls?q=is%3Apr+reviewed-by%3Afraxken\" title=\"Reviewed Pull Requests\"\u003e👀\u003c/a\u003e \u003ca href=\"https://github.com/MyUnisoft/HTML-PDF/commits?author=fraxken\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/PierreDemailly\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/39910767?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePierreD\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/MyUnisoft/HTML-PDF/commits?author=PierreDemailly\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyunisoft%2Fhtml-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyunisoft%2Fhtml-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyunisoft%2Fhtml-pdf/lists"}