{"id":16476978,"url":"https://github.com/agilgur5/pdf-to-dataurl","last_synced_at":"2026-06-04T21:31:47.120Z","repository":{"id":57321456,"uuid":"68055844","full_name":"agilgur5/pdf-to-dataURL","owner":"agilgur5","description":"A tiny wrapper around pdf.js to convert PDFs to dataURLs","archived":false,"fork":false,"pushed_at":"2016-10-01T22:56:52.000Z","size":6,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-24T17:49:59.046Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/agilgur5.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}},"created_at":"2016-09-12T23:18:14.000Z","updated_at":"2019-12-08T01:13:35.000Z","dependencies_parsed_at":"2022-08-25T22:41:38.434Z","dependency_job_id":null,"html_url":"https://github.com/agilgur5/pdf-to-dataURL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fpdf-to-dataURL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fpdf-to-dataURL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fpdf-to-dataURL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Fpdf-to-dataURL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agilgur5","download_url":"https://codeload.github.com/agilgur5/pdf-to-dataURL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241180829,"owners_count":19923298,"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-10-11T12:44:09.455Z","updated_at":"2026-06-04T21:31:47.114Z","avatar_url":"https://github.com/agilgur5.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pdf-to-dataURL\n\n[![NPM](https://nodei.co/npm/pdf-to-dataURL.png)](https://npmjs.org/package/pdf-to-dataURL)\n\nA tiny wrapper around [pdf.js](https://github.com/mozilla/pdf.js) to convert\nPDFs to dataURLs.\n\n## Installation\n\n`npm i -S pdf-to-dataURL`\n\n## Usage\n\npdfToDataURL is an async function (due to the async nature of pdf.js), that\naccepts a Blob of the PDF (e.g. from an `\u003cinput type='file' /\u003e` element), the\nwidth of the viewport the dataURL should fit in (for proper sizing), and a\ncallback that will be called after each page of the PDF is converted with a\npage object.\n\nThe page object has four properties:\n- `width`: `number` the width of the page's dataURL\n- `height`: `number` the height of the page's dataURL\n- `src`: `dataURL` the dataURL of the page\n- `index`: `number` the index of the page -- as pdf.js is async, the callback may\n  be called not in the correct page order. Use this property if the order of\n  the pages matters to you to properly place into an array.\n  Useful with rendering libraries like React, where you can easily control the\n  ordering of elements in the DOM.\n\n### Example\n\n```\nimport pdfToDataURL from 'pdf-to-dataURL'\nconst viewportWidth = 800\n\nlet initialNumChildren = document.body.children.length\n\nconst cb = function (page) {\n  let img = document.createElement('img')\n  img.width = page.width\n  img.height = page.height\n  img.src = page.src // the dataURL is here\n\n  document.body.appendChild(img)\n}\n\npdfToDataURL(pdfBlob, viewportWidth, cb)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilgur5%2Fpdf-to-dataurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagilgur5%2Fpdf-to-dataurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilgur5%2Fpdf-to-dataurl/lists"}