{"id":28146329,"url":"https://github.com/yakovmeister/pdf2image","last_synced_at":"2026-01-20T17:19:34.537Z","repository":{"id":43002355,"uuid":"106502032","full_name":"yakovmeister/pdf2image","owner":"yakovmeister","description":"A utility for converting pdf to image and base64 format.","archived":false,"fork":false,"pushed_at":"2025-05-31T01:56:13.000Z","size":45378,"stargazers_count":486,"open_issues_count":26,"forks_count":154,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-10-29T06:12:52.715Z","etag":null,"topics":["graphicsmagick","node-pdf","node-pdf-to-image","node-pdf2img","pdf","pdf-to-image"],"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/yakovmeister.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}},"created_at":"2017-10-11T03:40:03.000Z","updated_at":"2025-10-19T19:21:15.000Z","dependencies_parsed_at":"2024-06-18T12:30:45.085Z","dependency_job_id":"5b9b5921-6928-422a-84f7-e25a5926047c","html_url":"https://github.com/yakovmeister/pdf2image","commit_stats":{"total_commits":175,"total_committers":19,"mean_commits":9.210526315789474,"dds":0.6857142857142857,"last_synced_commit":"4e172f635b724b09bfb7c34e48d3a6d975c24edf"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/yakovmeister/pdf2image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakovmeister%2Fpdf2image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakovmeister%2Fpdf2image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakovmeister%2Fpdf2image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakovmeister%2Fpdf2image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yakovmeister","download_url":"https://codeload.github.com/yakovmeister/pdf2image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yakovmeister%2Fpdf2image/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"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":["graphicsmagick","node-pdf","node-pdf-to-image","node-pdf2img","pdf","pdf-to-image"],"created_at":"2025-05-14T23:12:28.728Z","updated_at":"2026-01-20T17:19:34.502Z","avatar_url":"https://github.com/yakovmeister.png","language":"TypeScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=938FMCPPQG4DQ\u0026currency_code=USD\u0026source=url","https://www.paypal.com/paypalme/yakovmeister"],"categories":["TypeScript","📦 Modules/Packages"],"sub_categories":[":curly_loop: Typography"],"readme":"# pdf2pic\n\n[![Donate][paypal-image]](https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=938FMCPPQG4DQ\u0026currency_code=USD\u0026source=url)\n![Build Status][github-actions-url]\n[![CodeFactor](https://www.codefactor.io/repository/github/yakovmeister/pdf2image/badge)](https://www.codefactor.io/repository/github/yakovmeister/pdf2image)\n[![Maintainability](https://api.codeclimate.com/v1/badges/6d7bfbae9057998bda99/maintainability)](https://codeclimate.com/github/yakovmeister/pdf2image/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/6d7bfbae9057998bda99/test_coverage)](https://codeclimate.com/github/yakovmeister/pdf2image/test_coverage)\n[![install size](https://packagephobia.com/badge?p=pdf2pic)](https://packagephobia.com/result?p=pdf2pic)\n[![NPM Version][npm-image]][npm-url]\n[![License](https://img.shields.io/npm/l/pdf2pic?color=blue)][npm-url]\n[![Known Vulnerabilities](https://snyk.io/test/npm/pdf2pic/badge.svg)](https://snyk.io/test/npm/pdf2pic)\n[![Downloads Stats][npm-downloads]][npm-url]\n\nA utility for converting pdf to image, base64 or buffer format.\n\n\u003e IMPORTANT NOTE: Please support this library by donating via [PayPal](https://www.paypal.com/paypalme/yakovmeister), your help is much appreciated. Contributors are also welcome!\n\n## Prerequisites\n\n* node \u003e= 14.x \n* graphicsmagick\n* ghostscript\n\n### Don't have graphicsmagick and ghostscript yet?\n\nFollow [this](docs/gm-installation.md) guide to install the required dependencies.\n\n## Installation\n\n```\nnpm install --save pdf2pic\n```\n\n## Usage\n\n### Converting specific page of PDF from path, then saving as image file\n\n```javascript\nimport { fromPath } from \"pdf2pic\";\n\nconst options = {\n  density: 100,\n  saveFilename: \"untitled\",\n  savePath: \"./images\",\n  format: \"png\",\n  width: 600,\n  height: 600\n};\nconst convert = fromPath(\"/path/to/pdf/sample.pdf\", options);\nconst pageToConvertAsImage = 1;\n\nconvert(pageToConvertAsImage, { responseType: \"image\" })\n  .then((resolve) =\u003e {\n    console.log(\"Page 1 is now converted as image\");\n\n    return resolve;\n  });\n```\n\n### Nuff talk, show me how:\nMore usage example can be found [here](https://github.com/yakovmeister/pdf2pic-examples).\n\n## pdf2pic API\n\n- [fromPath(filePath, options)](#frompathfilepath-options)\n- [fromBuffer(buffer, options)](#frombufferbuffer-options)\n- [fromBase64(b64string, options)](#frombase64b64string-options)\n\n### fromPath(filePath, options)\n\nInitialize PDF to image conversion by supplying a file path\n\n#### Functions\n\nConvert a specific page of the PDF to Image/Base64/Buffer by supplying a file path\n\n```javascript\nfromPath(filePath, options)(page, convertOptions)\n```\n* filePath - pdf file's path\n* options - see [options](#options).\n* page - page number to convert to an image\n* convertOptions - see [convertOptions](#convertoptions).\n\n---\n\nConverts PDF to Image/Base64/Buffer by supplying a file path\n```javascript\nfromPath(filePath, options).bulk(pages, convertOptions)\n```\n* filePath - pdf file's path\n* options - see [options](#options).\n* pages - page numbers to convert to image\n  * set `pages` to `-1` to convert all pages\n  * `pages` also accepts an array indicating the page number e.g. `[1,2,3]`\n  * also accepts number e.g. `1`\n* convertOptions - see [convertOptions](#convertoptions)\n\n---\n\nSet GraphicsMagick's subclass or path\n```javascript\nfromPath(filePath, options).setGMClass(subClass)\n```\nNOTE: should be called before calling `convert()` or `bulk()`.\n* filePath - pdf file's path\n* options - see [options](#options).\n* subClass - path to gm binary or set to true to use imagemagick\n  * set `subClass` to true to use imagemagick\n  * supply a valid path as `subClass` to locate gm path specified\n\n---\n\n### fromBuffer(buffer, options)\n \nInitialize PDF to image conversion by supplying a PDF buffer\n\n#### Functions\n\nConvert a specific page of the PDF to Image/Base64/Buffer by supplying a buffer\n```javascript\nfromBuffer(buffer, options)(page, convertOptions)\n```\n\nFunctions same as `fromPath(filePath, options)(page, convertOptions)` only input is changed\n\n---\nConverts PDF to Image/Base64/Buffer by supplying a buffer:\n\n```javascript\nfromBuffer(buffer, options).bulk(pages, convertOptions)\n```\n\nFunctions same as `fromPath(filePath, options).bulk(pages, convertOptions)` only input is changed\n\n---\nSet GraphicsMagick's subclass or path:\n```javascript\nfromBuffer(buffer, options).setGMClass(subClass)\n```\n\nFunctions same as `fromPath(filePath, options).setGMClass(subClass)` only input is changed\n\n---\n\n### fromBase64(b64string, options)\nInitialize PDF to image conversion by supplying a PDF base64 string.\n\n#### Functions\nConvert a specific page of the PDF to Image/Base64/Buffer by supplying a base64 string:\n```javascript\nfromBase64(b64string, options)(page, convertOptions)\n```\n\nFunctions same as `fromPath(filePath, options)(page, convertOptions)` only input is changed.\n\n---\nConverts PDF to Image/Base64/Buffer by supplying a base64 string:\n\n```javascript\nfromBase64(b64string, options).bulk(pages, convertOptions)\n```\n\nFunctions same as `fromPath(filePath, options).bulk(pages, convertOptions)` only input is changed.\n\n---\nSet GraphicsMagick's subclass or path:\n```javascript\nfromBase64(b64string, options).setGMClass(subClass)\n```\n\nFunctions same as `fromPath(filePath, options).setGMClass(subClass)` only input is changed.\n---\n### options\nFollowing are the options that can be passed on the pdf2pic api:\n\n| option              | default value | description                                                                                                                                                                                                                                                                   |\n|---------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| quality             | `0`           | Image compression level. Value depends on `format`, usually from `0` to `100` ([more info](http://www.graphicsmagick.org/GraphicsMagick.html#details-quality))                                                                                                                |\n| format              | `'png'`       | Formatted image characteristics / image format ([image characteristics](http://www.graphicsmagick.org/GraphicsMagick.html#details-format), [image format](http://www.graphicsmagick.org/formats.html))                                                                        |\n| width               | `768`         | Output width                                                                                                                                                                                                                                                                  |\n| height              | `512`         | Output height                                                                                                                                                                                                                                                                 |\n| preserveAspectRatio | `false`       | Maintains the aspect ratio of the image. When set to `true` and both `width` and `height` are specified, they are interpreted as the minimum width and minimum height, respectively. If set to `true` with only the `width` specified, the `height` will be automatically determined while preserving the aspect ratio, and vice versa. |\n| density             | `72`          | Output DPI (dots per inch) ([more info](http://www.graphicsmagick.org/GraphicsMagick.html#details-density))                                                                                                                                                                   |\n| savePath            | `'./'`        | Path where to save the output                                                                                                                                                                                                                                                 |\n| saveFilename        | `'untitled'`  | Output filename                                                                                                                                                                                                                                                               |\n| compression         | `'jpeg'`      | Compression method ([more info](http://www.graphicsmagick.org/GraphicsMagick.html#details-compress))                                                                                                                                                                          |\n\n### convertOptions\n\n| option       | default value | description |\n|--------------|---------------|-------------|\n| responseType | `image`       | Response type of the output. Accepts: `image`, `base64` or `buffer` |\n\nThe parameter can also be a boolean, if `true` then the response type will be `base64` and if `false` then the response type will be `image`. \nThis is deprecated and will be removed in the next major version.\n\n## Contributing\n* Fork it (https://github.com/yakovmeister/pdf2image/fork)\n* Create your feature branch (git checkout -b feature/make-maintainer-cry)\n* Commit your changes (git commit -am 'feature: make maintainer cry by running git rm -rf')\n* Push to the branch (git push origin feature/make-maintainer-cry)\n* Create a new PR\n\n## License\npdf2pic is [MIT licensed](LICENSE).\n\n\u003c!-- Markdown link \u0026 img dfn's --\u003e\n[npm-image]: https://img.shields.io/npm/v/pdf2pic.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/pdf2pic\n[npm-downloads]: https://img.shields.io/npm/dm/pdf2pic.svg?style=flat-square\n[github-actions-url]: https://github.com/yakovmeister/pdf2image/actions/workflows/test.yml/badge.svg?branch=master\n[paypal-image]: https://img.shields.io/badge/Donate-PayPal-green.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakovmeister%2Fpdf2image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyakovmeister%2Fpdf2image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyakovmeister%2Fpdf2image/lists"}