{"id":15699952,"url":"https://github.com/eemeli/pdf-form-fill","last_synced_at":"2025-05-12T12:43:46.604Z","repository":{"id":57321400,"uuid":"88104714","full_name":"eemeli/pdf-form-fill","owner":"eemeli","description":"PDF form fill with UTF-8 support, using pdftk","archived":false,"fork":false,"pushed_at":"2017-04-14T18:04:02.000Z","size":12,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-12T01:46:39.129Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eemeli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-12T23:16:39.000Z","updated_at":"2024-05-21T11:00:46.000Z","dependencies_parsed_at":"2022-08-25T22:41:32.652Z","dependency_job_id":null,"html_url":"https://github.com/eemeli/pdf-form-fill","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/eemeli%2Fpdf-form-fill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eemeli%2Fpdf-form-fill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eemeli%2Fpdf-form-fill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eemeli%2Fpdf-form-fill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eemeli","download_url":"https://codeload.github.com/eemeli/pdf-form-fill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253742777,"owners_count":21957092,"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-03T19:42:56.902Z","updated_at":"2025-05-12T12:43:46.584Z","avatar_url":"https://github.com/eemeli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pdf-form-fill\n\nSimple PDF form fill, using [PDFtk]. Uses field data in `xfdf` format to help guarantee UTF-8 support.\n\nAll operations are non-blocking. Written in a rather ES6-ish style; use on Node 5.x and earlier will require transpiling.\n\nRelease as open source under the [ISC license].\n\n\n### Installation\n\n1. Make sure `pdftk` is available in your environment, preferably at least version 2.02.\n2. `npm install pdf-form-fill`\n\n\n### Usage\n\nThe API is minimal:\n- `fields(pdf)` will return a [Promise] resolving with a simple object describing the PDF's available fields.\n- `fill(pdf, fields[, options])` will return a promise resolving with a [Readable sream] of the output PDF. the\n  following `options` are supported:\n  - `flatten`: Flatten the resulting PDF (default `true`)\n  - `info`: Info fields to be set in the output, such as `CreationTime`, `ModTime`, `Title`, `Author`, etc. Time\n    values should be Date objects; all others should be strings.\n  - `verbose`: Print stuff to the console (default `false`)\n\nOn error, the promises returned by both functions will reject with an Error object. For more details, read the\n[source code](index.js).\n\nSetting any info values will require spawning a second pdftk instance and writing an intermediate PDF to a temporary\nfile (piping pdf output to pdftk turns out to be rather flaky). This will slow down the processing a bit; use\n`options.verbose` to test the execution time on your systems.\n\n\n### Example\n\n```js\nconst fs = require('fs')\nconst { fields, fill } = require('pdf-form-fill')\n\nconst srcPdf = '...'\nconst tgtPdf = '...'\nconst fields = { name1: 'Value 1', checkbox2: 'Yes' }\n\nfields(srcPdf)\n  .then(shape =\u003e console.log(shape))\n  .catch(err =\u003e console.error(err))\n\nconst output = fs.createWriteStream(tgtPdf)\nfill(scrPdf, fields)\n  .then(stream =\u003e stream.pipe(output))\n  .catch(err =\u003e console.error(err))\n```\n\nFor a more complete example, see the [pdf-form-fill-server] source code.\n\n\n### Notes\n\nThis tool is the product of frustration and incredulity, as none of the other PDF form-filling tools appeared to\nwork for my particular use case, requiring UTF-8 support in a macOS environment. For some reason, that works with\n`xfdf` form data, but not with `fdf`. But then, of course, PDFtk isn't able to read that from stdin (unlike `fdf`,\nof course), so it needs to be written to a temporary file for it.\n\nSome aspects of this code were inspired by [pdffiller-stream], but all the code was written from scratch for this.\n\n\n[ISC license]: https://en.wikipedia.org/wiki/ISC_license\n[pdf-form-fill-server]: https://github.com/eemeli/pdf-form-fill-server\n[pdffiller-stream]: https://www.npmjs.com/package/pdffiller-stream\n[PDFtk]: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/\n[Promise]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise\n[Readable sream]: https://nodejs.org/api/stream.html#stream_class_stream_readable\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feemeli%2Fpdf-form-fill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feemeli%2Fpdf-form-fill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feemeli%2Fpdf-form-fill/lists"}