{"id":24337793,"url":"https://github.com/hyzyla/pdfium","last_synced_at":"2025-04-04T15:05:08.681Z","repository":{"id":173975404,"uuid":"651587112","full_name":"hyzyla/pdfium","owner":"hyzyla","description":"Typescript wrapper for the PDFium library, works in browser and node.js","archived":false,"fork":false,"pushed_at":"2025-03-13T23:06:46.000Z","size":44630,"stargazers_count":71,"open_issues_count":8,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T01:09:00.719Z","etag":null,"topics":["javascript","nodejs","pdf"],"latest_commit_sha":null,"homepage":"https://pdfium.js.org","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/hyzyla.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":"2023-06-09T15:14:36.000Z","updated_at":"2025-03-26T08:15:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"419ef572-ac34-4503-bb19-1ed957d863ca","html_url":"https://github.com/hyzyla/pdfium","commit_stats":{"total_commits":145,"total_committers":4,"mean_commits":36.25,"dds":"0.26206896551724135","last_synced_commit":"757a019bf2c0b8b99b4fee2b660167e296cec26f"},"previous_names":["hyzyla/pdfium"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyzyla%2Fpdfium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyzyla%2Fpdfium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyzyla%2Fpdfium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyzyla%2Fpdfium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyzyla","download_url":"https://codeload.github.com/hyzyla/pdfium/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246757023,"owners_count":20828813,"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":["javascript","nodejs","pdf"],"created_at":"2025-01-18T06:17:36.837Z","updated_at":"2025-04-04T15:05:08.661Z","avatar_url":"https://github.com/hyzyla.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @hyzyla/pdfium\n\n📃 [Documentation](https://pdfium.js.org/docs/intro)\n\nTypeScript/JavaScript wrapper for the PDFium library:\n\n- ⬇️ [pdfium](https://pdfium.googlesource.com/pdfium/) - source code of the PDFium library, developed by Google and used in Chrome.\n- ⬇️ [pdfium-lib](https://github.com/paulocoutinhox/pdfium-lib) - project to compile PDFium library to multiple platforms, including WebAssembly.\n- 📍 [@hyzyla/pdfium](https://github.com/hyzyla/pdfium) - (you are here)\n TypeScript/JavaScript wrapper for the WebAssembly build of PDFium library.\n\n# Features\n-  📦 Zero dependencies - PDFium library is compiled to WebAssembly and bundled with the package.\n- 🚀 Fast - PDFium can be faster than PDF.js, because it's originally written in C++ and compiled to WebAssembly, while PDF.js is entirely written in JavaScript.\n- 🔒 Type-safe - TypeScript definitions are included.\n- 🗼 Works in browser and Node.js\n\n## Installation\n\n```sh\n# yarn add @hyzyla/pdfium\n# pnpm install @hyzyla/pdfium\nnpm install @hyzyla/pdfium\n```\n\n## Usage\n\n```ts\nimport { PDFiumLibrary } from \"@hyzyla/pdfium\";\nimport { promises as fs } from 'fs';\nimport sharp from 'sharp';\n\n\n/**\n * For this and the following examples, we will use \"sharp\" library to convert\n * the raw bitmap data to PNG images. You can use any other library or write\n * your own function to convert the raw bitmap data to PNG images.\n */\nasync function renderFunction(options: PDFiumPageRenderOptions) {\n  return await sharp(options.data, {\n    raw: {\n      width: options.width,\n      height: options.height,\n      channels: 4,\n    },\n  })\n    .png()\n    .toBuffer();\n}\n\n\nasync function main() {\n  const buff = await fs.readFile('test2.pdf');\n\n  // Initialize the library, you can do this once for the whole application\n  // and reuse the library instance.\n  const library = await PDFiumLibrary.init();\n\n  // Load the document from the buffer\n  // You can also pass \"password\" as the second argument if the document is encrypted.\n  const document = await library.loadDocument(buff);\n\n  // Iterate over the pages, render them to PNG images and\n  // save to the output folder\n  for (const page of document.pages()) {\n    console.log(`${page.number} - rendering...`);\n\n    // Render PDF page to PNG image\n    const image = await page.render({\n      scale: 3, // 3x scale (72 DPI is the default)\n      render: renderFunction,  // sharp function to convert raw bitmap data to PNG\n    });\n\n    // Save the PNG image to the output folder\n    await fs.writeFile(`output/${page.number}.png`, Buffer.from(image.data));\n  }\n\n  // Do not forget to destroy the document and the library\n  // when you are done.\n  document.destroy();\n  library.destroy();\n}\n\nmain();\n```\n\n\n## Release\n\n1. Bump version in `package.json`: `npm version patch`\n2. Create a new release in GitHub\n3. Check status of the [GitHub Actions](https://github.com/hyzyla/pdfium/actions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyzyla%2Fpdfium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyzyla%2Fpdfium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyzyla%2Fpdfium/lists"}