{"id":20709440,"url":"https://github.com/balaji-atoa/puppe-pdf","last_synced_at":"2025-07-13T19:06:19.748Z","repository":{"id":259883166,"uuid":"861666765","full_name":"balaji-atoa/puppe-pdf","owner":"balaji-atoa","description":"an npm package to convert HTML or any website to pdf flawlessly in seconds using puppeteer/chromium!","archived":false,"fork":false,"pushed_at":"2024-10-29T10:27:59.000Z","size":419,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T19:02:34.732Z","etag":null,"topics":["htmlpdf","htmltopdf","node","pdf","pdf-generation","puppeteer"],"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/balaji-atoa.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-23T10:06:50.000Z","updated_at":"2024-10-29T10:28:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"a23c3615-1a71-4a54-b608-064b81748e12","html_url":"https://github.com/balaji-atoa/puppe-pdf","commit_stats":null,"previous_names":["balaji-atoa/puppe-pdf"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/balaji-atoa/puppe-pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balaji-atoa%2Fpuppe-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balaji-atoa%2Fpuppe-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balaji-atoa%2Fpuppe-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balaji-atoa%2Fpuppe-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/balaji-atoa","download_url":"https://codeload.github.com/balaji-atoa/puppe-pdf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balaji-atoa%2Fpuppe-pdf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265191062,"owners_count":23725252,"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":["htmlpdf","htmltopdf","node","pdf","pdf-generation","puppeteer"],"created_at":"2024-11-17T02:06:06.993Z","updated_at":"2025-07-13T19:06:19.739Z","avatar_url":"https://github.com/balaji-atoa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/puppe-pdf.svg)](https://badge.fury.io/js/puppe-pdf)\n[![Node version](https://img.shields.io/node/v/puppe-pdf.svg?style=flat)](https://nodejs.org/download/)\n![GitHub CI](https://github.com/balaji-atoa/puppe-pdf/actions/workflows/run-tests.yaml/badge.svg)\n[![HitCount](https://hits.dwyl.com/balaji-atoa/puppe-pdf.svg?style=flat-square\u0026show=unique)](http://hits.dwyl.com/balaji-atoa/puppe-pdf)\n# puppe-pdf\n\nconvert HTML or any website to pdf flawlessly in seconds! puppe-pdf includes built-in TypeScript support, with type definitions provided for all exports.\n\n\n## Table of Contents\n\n- [Installation](#installation)\n\n- [Usage](#usage)\n\n- [API Reference](#api-reference)\n\n- [Options](#options)\n\n- [Troubleshooting](#troubleshooting)\n\n- [Contributions](#contributions)\n\n  \n\n## Installation\n\nTo install the package, run the following command in your project directory:\n\n`npm install puppe-pdf`\n\n## Usage\nHere is a **minimal express starter** for reference. Checkout [here](examples/example.ts) for a typescript example.\n```\nconst express = require('express')\nconst server = express()\nconst puppePdf = require('../src/index')\n\nserver.get('/', async (_, res) =\u003e {\n  const pdfBuffer = await puppePdf.forgePDF('https://pptr.dev/guides/what-is-puppeteer')\n  res.header('Content-Type', 'application/pdf')\n  res.status(200).send(pdfBuffer)\n})\n\nserver.listen(3000, () =\u003e {\n  console.log('Server initialized')\n})\n```\n  \n## API Reference\n\n`forgePDF(otps:  Options  |  string):Promise\u003cBuffer  |  Readable  |  Uint8Array\u003e`\n\nGenerates a PDF from a URL or HTML string, providing several customization options for fine-tuning output.\n\n### Parameters\n-  `options` (Options | string): If a `string` is provided, it’s treated as a URL to be visited. Alternatively, an `Options` object can be passed to specify additional settings.\n\n### Returns \n-   `Promise\u003cBuffer | Readable | Uint8Array\u003e`  \n    Returns a `Promise` that resolves to the generated PDF in the specified format: a `Buffer`, a `Readable` stream, or a `Uint8Array`. The default output would be a `Buffer`. If `stream` in options is set to true, `Readable` stream will be returned. If `raw` is set to true, the raw `Uint8Array` from puppeteer is returned.\n\n \n## Options\n\n  \n| Option                  | Type                      | Description                                                                                                                                           |\n|-------------------------|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `url`                   | `string`                  | The URL to visit for generating the PDF. Required if `html` is not provided.                                                                          |\n| `html`                  | `string`                  | HTML content to render directly on the page, which is faster than loading a URL. Required if `url` is not provided.                                   |\n| `launchOpts`            | [LaunchOptions](https://pptr.dev/api/puppeteer.launchoptions)           | Puppeteer’s launch options for customizing the browser instance (headless mode, executable path, etc.).                                               |\n| `goToOptions`           | [GoToOptions](https://pptr.dev/api/puppeteer.gotooptions)             | Options to configure Puppeteer’s `page.goto()` method, like navigation timeout or waitUntil conditions.                                               |\n| `waitForSelector`       | `string`                  | CSS selector for an element that must be visible before the PDF generation begins.                                                                    |\n| `waitForSelectorOpts`   | [WaitForSelectorOptions](https://pptr.dev/api/puppeteer.waitforselectoroptions)  | Options for waiting on the selector, such as visibility conditions and timeout.                                                                       |\n| `pdfOpts`               | [PDFOptions](https://pptr.dev/api/puppeteer.pdfoptions)              | Puppeteer’s PDF options, like page format, margins, and print background settings.                                                                    |\n| `saveToFile`            | `boolean`                 | If `true`, saves the PDF to a file instead of returning it as a `Buffer`. Specify the file path in `pdfOpts`.                                         |\n| `raw`                   | `boolean`                 | When `true`, returns the PDF in `Uint8Array` format for direct binary manipulation.                                                                   |\n| `stream`                | `boolean`                 | If `true`, returns the PDF as a readable stream instead of a `Buffer`.                                                                                |\n| `disableJavascript`     | `boolean`                 | If `true`, disables JavaScript execution on the page, useful for static content.                                                                      |\n| `cookies`               | [CookieParam[]](https://pptr.dev/api/puppeteer.cookieparam)           | List of cookies to inject into the page for authentication or session management.                                                                     |\n\n\n\n## Troubleshooting\n\n  https://pptr.dev/guides/debugging\n\n## Instructions to run docker in local\n\nSetup docker desktop on local, run the below commands one by one.\n\n\n`docker build -t puppeteer-app .`\n\n\n`docker run -p 3000:3000 puppeteer-app`\n\n\n## Contributions\n\nContributions are welcome! If you have ideas for new features, bug fixes, or general improvements, feel free to contribute to this project. Please follow these steps to ensure a smooth process:\n\n  \n\n- **Fork the repository**: Click on the \"Fork\" button at the top of the repository page to create your own fork.\n\n- **Clone your fork**: Clone the forked repository to your local machine.\n\n```\ngit clone https://github.com/your-username/puppe-pdf.git\n```\n\n-   **Make your changes**: Make changes directly in the `main` branch of your forked repository. Make sure to **add testcases**. \n-   **Test your changes**: Ensure your changes are thoroughly tested locally.\n-   Push changes to your fork's main\n ``` \n git add .\n git commit -m \"short description of your change\"\n git push origin main\n ```\n -   **Submit a Pull Request (PR)**: Go to the original repository and submit a pull request from your fork’s `main` branch to the original repository’s `main` branch.\n## License\n\nThis project is licensed under the [MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalaji-atoa%2Fpuppe-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbalaji-atoa%2Fpuppe-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalaji-atoa%2Fpuppe-pdf/lists"}