{"id":22428336,"url":"https://github.com/momsfriendlydevco/pdf-dicer","last_synced_at":"2025-09-20T11:42:46.637Z","repository":{"id":57321384,"uuid":"78503238","full_name":"MomsFriendlyDevCo/pdf-dicer","owner":"MomsFriendlyDevCo","description":"Split PDF files into many based on barcode separators","archived":false,"fork":false,"pushed_at":"2020-07-17T04:56:16.000Z","size":1906,"stargazers_count":21,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-29T23:28:58.283Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MomsFriendlyDevCo.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":"2017-01-10T06:08:22.000Z","updated_at":"2023-11-14T19:52:15.000Z","dependencies_parsed_at":"2022-08-25T20:10:51.542Z","dependency_job_id":null,"html_url":"https://github.com/MomsFriendlyDevCo/pdf-dicer","commit_stats":null,"previous_names":["hash-bang/pdf-dicer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpdf-dicer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpdf-dicer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpdf-dicer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fpdf-dicer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MomsFriendlyDevCo","download_url":"https://codeload.github.com/MomsFriendlyDevCo/pdf-dicer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228363964,"owners_count":17908319,"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-12-05T20:14:28.521Z","updated_at":"2025-09-20T11:42:46.546Z","avatar_url":"https://github.com/MomsFriendlyDevCo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"PDF-Dicer\n=========\nSplit PDF files into many based on barcode separators.\n\nThis is useful if scanning a large number of documents in a batch (e.g. via an automated office scanner) which then need to be split up again.\n\nPDF-Dicer takes a single PDF file made up of multiple scanned documents. Each sub-document has a starting and ending barcode.\n\n![Input file](docs/input.png)\n\n\nPDF-Dicer takes this file, splits on each barcode set, validates the barcodes and outputs back into individual files.\n\n![Output process](docs/output.png)\n\n\nInstalling\n----------\nThis module requires ImageMagick, GhostScript and Poppler.\n\nYou can install them as follows:\n\n* **Ubuntu Linux** - `sudo apt-get install imagemagick ghostscript poppler-utils pdftk`\n  * NOTE: Some versions of Ubuntu do not stock PDFTK, use `sudo add-apt-repository -y ppa:mike-quisido/pdftk \u0026\u0026 sudo apt-get update \u0026\u0026 sudo apt -y install pdftk-java`\n  * PDFTK also requires [permissions to be setup](https://stackoverflow.com/a/52661288/1295040) before it can process local files\n* **OSX (Yosemite)** - `brew install imagemagick ghostscript poppler`\n  * Install [PDFTK](https://www.pdflabs.com/tools/pdftk-server/#download) from website.\n\n\nExample\n-------\n```javascript\nvar pdfDicer = require('pdf-dicer');\n\nvar dicer = new pdfDicer();\n\ndicer\n\t.on('split', (data, buffer) =\u003e {\n\t  fs.writeFile('output.pdf', buffer);\n\t})\n\t.split('input.pdf', function(err, output) {\n\t\tif (err) console.log(`Something went wrong: ${err}`);\n\t});\n```\n\nThere is an also an example of reading a directory of PDF's and saving based on extracted barcodes [here](./examples/export.js)\n\n\nAPI\n===\n\ndicer (class)\n-------------\nThe main class of this module.\n\nThe constructor takes an optional settings object which is used to populate the initial setup.\n\n```javascript\nvar dicer = new pdfDicer({driver: 'quagga'});\n```\n\ndicer.settings (object)\n-----------------------\nAn object of the instance settings. These can be set either on construction, via a call to `set()` or directly.\n\nThe following settings are supported:\n\n| Setting                     | Type      | Default                                           | Profile   | Description                                                                      |\n|-----------------------------|-----------|---------------------------------------------------|-----------|----------------------------------------------------------------------------------|\n| `areas`                     | Array     | `{top:'0%',right:'0%',left:'0%',bottom:'0%'}`       | Quagga    | The areas of the input pages that Quagga should scan                             |\n| `imageFormat`               | String    | `png` (Quagga), `tif` (Bardecode)                 | All       | The intermediate image format to use before processing the barcode               |\n| `magickOptions`             | Object    | Various (Quagga), `{}` (Bardecode)                | All       | Additional options to pass to ImageMagick when converting the PDF to images      |\n| `bardecode`                 | Object    | See below                                         | Bardecode | Options specific to Bardecode                                                    |\n| `bardecode.bin`             | String    | `/opt/bardecoder/bin/bardecode`                   | Bardecode | Path to the `bardecode` binary                                                   |\n| `bardecode.checkEvaluation` | Boolean   | `true`                                            | Bardecode | Check that the barcode doesn't end in `???` and raise a warning if it does       |\n| `bardecode.serial`          | String    | `\"\"`                                              | Bardecode | Your Bardecode serial number                                                     |\n| `filter`                    | Function  | `(page) =\u003e true`                                  | All       | Optional filter to discard pages before calculating ranges                       |\n| `quagga`                    | Object    | See below                                         | Quagga    | Options specific to Quagga                                                       |\n| `quagga.locate`             | Boolean   | `false`                                           | Quagga    | Indicates if Quagga should try to detect the barcode or we should use areas      |\n| `quagga.decoder`            | Object    | `{readers:['code_128_reader'],multiple: false}`   | Quagga    | Options passed to the Quagga decoder                                             |\n| `temp`                      | Object    | See below                                         | All       | Options passed to Temp when generating a temporary directory                     |\n| `tempClean`                 | Boolean   | `true`                                            | All       | Automatically erase the temporary directory when done                            |\n| `temp.prefix`               | String    | `pdfdicer-`                                       | All       | The prefix used when generating a temporary directory                            |\n| `threads`                   | Object    | See below                                         | All       | Options used for async threading                                                 |\n| `threads.pages`             | Number    | `1`                                               | All       | The number of threads allowed to run simultaneously when processing pages        |\n| `threads.areas`             | Number    | `1`                                               | Quagga    | The number of threads allowed to run simultaneously when processing page areas   |\n\n\ndicer.set(setting, value)\n-------------------------\nConvenience function to quickly set a setting. Dotted notation is allowed for `setting`.\n\n\ndicer.profile(profile)\n----------------------\nConvenience function to configure the module with optimal settings for the supported barcode readers.\n\nSupported profiles are:\n\n* `quagga`\n* `bardecode`\n\n\ndicer.split(inputPath, callback)\n--------------------------------\nProcess the inputPath (usually a PDF) and split it into multiple PDF files.\n\nHook into the output of this function by trapping events.\n\n\nEvents\n------\nThe following events are fired by this module:\n\n| Event             | Arguments            | Description                                                 |\n|-------------------|----------------------|-------------------------------------------------------------|\n| `stage`           | `(stageName)`        | Fired for each stage of operation. ENUM: 'init', 'readPDF', 'readPages', 'extracted', 'filtering', 'loadRange', 'preSplit' |\n| `tempDir`         | `(path)`             | Fired when a temp directory has been allocated              |\n| `pageConverted`   | `(page, pageOffset)` | Fired for each page that is converted                       |\n| `pagesConverted`  | `(pages)`            | Fired when all pages have been converted                    |\n| `pageAnalyze`     | `(page)`             | Fired before an individual page is analyzed                 |\n| `barcodeFiltered` | `(page)`             | Fired if a page is filtered out                             |\n| `barcodePassed`   | `(page)`             | Fired if a page passes filtering and is not filtered out    |\n| `pageAnalyzed`    | `(page)`             | Fired after a page has been analyzed                        |\n| `pagesAnalyzed`   | `(pages)`            | Fired when all pages have been analyzed                     |\n| `split`           | `(range, buffer)`    | Fired when a range has been detected and a buffer is ready  |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fpdf-dicer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmomsfriendlydevco%2Fpdf-dicer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fpdf-dicer/lists"}