{"id":13578521,"url":"https://github.com/tcr/scissors","last_synced_at":"2025-05-15T10:00:26.852Z","repository":{"id":5551779,"uuid":"6756046","full_name":"tcr/scissors","owner":"tcr","description":"PDF manipulation in Node.js! Split, join, crop, read, extract, boil, mash, stick them in a stew. ","archived":false,"fork":false,"pushed_at":"2025-02-19T23:31:33.000Z","size":465,"stargazers_count":286,"open_issues_count":11,"forks_count":45,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-14T16:53:43.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2012-11-19T06:45:01.000Z","updated_at":"2025-01-16T10:50:03.000Z","dependencies_parsed_at":"2024-11-17T04:00:43.825Z","dependency_job_id":"8c583469-e826-4263-beb8-aeac49cd9bec","html_url":"https://github.com/tcr/scissors","commit_stats":{"total_commits":110,"total_committers":15,"mean_commits":7.333333333333333,"dds":0.4818181818181818,"last_synced_commit":"5341c3b4c7aecd218d0fa0282761464cd353a046"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcr%2Fscissors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcr%2Fscissors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcr%2Fscissors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcr%2Fscissors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcr","download_url":"https://codeload.github.com/tcr/scissors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319715,"owners_count":22051072,"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-08-01T15:01:31.406Z","updated_at":"2025-05-15T10:00:26.115Z","avatar_url":"https://github.com/tcr.png","language":"JavaScript","readme":"# scissors\n[![.github/workflows/run_tests.yml](https://github.com/tcr/scissors/actions/workflows/run_tests.yml/badge.svg)](https://github.com/tcr/scissors/actions/workflows/run_tests.yml)\n\nPDF manipulation in Node.js, based on PDFTK! Split, join, crop, read, extract, \nboil, mash, stick them in a stew.\n\n\u003e This project is no longer actively maintained and we cannot respond to issues. \n\u003e Consider alternatives such as https://github.com/jjwilly16/node-pdftk \n\u003e \n\u003e Bug fixes are always welcome.\n\n## Example\n\n```javascript\nvar scissors = require('scissors');\n\n// Use and chain any of these commands...\nvar pdf = scissors('in.pdf')\n   .pages(4, 5, 6, 1, 12) // select or reorder individual pages\n   .range(1, 10) // pages 1-10\n   .even() // select even pages, \n   .odd() // or odd, \n   .rotate(90) // 90, 180, 270, 360 degrees\n   .reverse() // reverse the page order\n   .crop(100, 100, 300, 200) // offset in points from left, bottom, right, top (doesn't work reliably yet)\n   .pdfStream()... // output stream, see below\n   \n// Join multiple files...\nvar pdfA = scissors('1.pdf'), pdfB = scissors('2.pdf'), pdfC = scissors('3.pdf')\nscissors.join(pdfA.pages(1), pdfB, pdfC.pages(5, 10)).pdfStream()...\n\n// And output data as streams\npdf.pdfStream()\n   .pipe(fs.createWriteStream('out.pdf'))\n   .on('finish', function(){\n     console.log(\"We're done!\");\n   }).on('error',function(err){\n     throw err;\n   });\n\n// or use promises:\nrequire('stream-to-promise')(\n  scissors(pdf)\n  .pages(1,3)\n  .pdfStream().pipe(fs.createWriteStream(...)\n)\n.then(function(){\n   console.log(\"We're done!\");\n})\n.catch(function(e){\n   console.error(\"Something went wrong:\" + e);\n});\n\npdf.pngStream(300).pipe(fs.createWriteStream('out-page1.png')); // PNG of first page at 300 dpi\npdf.textStream().pipe(process.stdout) // Stream of individual text strings\npdf.propertyStream().pipe(process.stdout) // Stream of PDF meta data\n\n// Extract content as text or images:\npdf.contentStream().on('data', console.log)\n// { type: 'string', x: 1750, y: 594,\n//   string: 'Reinhold Messner',\n//   font: { height: 112, width: 116, font: 'ZSVUGH+Imago-Book' },\n//   color: { r: 137, g: 123, b: 126 } }\n// { type: 'image', x: 3049, y: 5680, width: 655, height: 810, index: 4 }\n\n// Use the 'index' property of an image element to extract an image:\n// Calls `pdfimages -j`, so the result format is dependent on the \n// format of the embedded image (see http://linuxcommand.org/man_pages/pdfimages1.html)\npdf.extractImageStream(0).pipe(s.createWriteStream('firstImage.jpg'));\n\n// Promise-based output:\npdf.getPageSizes().then(console.dir); // requires imagemagick\n// [\n//  {\n//    \"width\": \"595\",\n//    \"height\": \"842\",\n//    \"unit\": \"pt\"\n//  },\n//  ...\npdf.getNumPages().then(console.log); // prints the number of pages of the PDF\n\n```\n\n## Requirements\n\nScissors is a wrapper around command line utilities (mainly PDFTK) that have to \nbe separately installed.\n\n* Install [PDFTK](http://www.pdflabs.com/docs/install-pdftk/). For MacOS, see below.\n* Ensure you have Ghostscript installed (check by running `gs --version`).\n* To use the `getPageSizes` method, you need the imagemagick library, which provides the `identify` executable.\n* *(optional)* To extract individual images from a page with the \n  `extractImageStream()` method, install `pdfimages` with `brew install xpdf` or \n   `apt-get install poppler-utils`.\n\n## MacOS\n\nPDFTK does not run out-of-the box on Mac OS \u003e=10.11. A patched build is\navailable\n[here](https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg)\nas per [this\nthread](http://stackoverflow.com/questions/32505951/pdftk-server-on-os-x-10-11).\nAlternatively, use a dockerized executable such as\nhttps://hub.docker.com/r/jottr/alpine-pdftk. Remember that, in this case,  you\nneed to pass read streams to the executable instead of file paths unless you\nmount the directories containing these paths to make them accessible for the\ndocker image.\n\n## Testing\n\nThe tests sometimes and unpredictably fail for unknown reasons, try to run them again to see whether the\nproblem goes away.\n\n## Dev resources\n- https://www.pdflabs.com/docs/pdftk-man-page/\n\n## Known issues\n- `.crop()` doesn't work reliably, if at all.\n","funding_links":[],"categories":["JavaScript","JAVASCRIPT"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcr%2Fscissors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcr%2Fscissors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcr%2Fscissors/lists"}