pdf-forms
Version:
Easily fill out form fields in PDF files
32 lines (20 loc) • 723 B
Markdown
out form fields in PDF files
- `.load(fileOrBuffer)`: returns a PDF object
- PDF
- `.getFields()`: Returns an object where the key is the field id and the value is the field description
- `.fillOut(values)`: Takes an object, values, where the key is the field id and the value is the field value
- Returns a buffer with a filled out PDF
```js
const Forms = require('pdf-forms')
const yourTaxes = Forms.load('./tax-form.pdf')
const fields = await yourTaxes.getFields()
const fillIn = {}
for (const key in fields) { // fill everything with a 0
fillIn[key] = '0'
}
const filledOut = await yourTaxes.fillOut(fillIn)
fs.writeFileSync('./filled-out.pdf', filledOut)
```
Easily fill