Skip to content

Take an existing PDF Form and data and PDF Filler will create a new PDF with all given fields populated.

License

Notifications You must be signed in to change notification settings

AppPress/pdffiller

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Filler (Node.js) ====== A node.js PDF form field data filler and FDF generator toolkit. This essentially is a wrapper around the PDF Toolkit library PDF ToolKit. On OS X 10.11, you must use this version: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg Quick start ----------- First, run `npm install pdffiller --save` for your app. Then: ```js var pdfFiller = require('pdffiller'); // ... ``` ##Examples #### 1.Fill PDF with existing FDF Data ````javascript var pdfFiller = require('pdffiller'); var sourcePDF = "test/test.pdf"; var outputPDF = "test/test_complete.pdf"; var data = { "last_name" : "John", "first_name" : "Doe", "date" : "Jan 1, 2013", "football" : "Off", "baseball" : "Yes", "basketball" : "Off", "hockey" : "Yes", "nascar" : "Off" }; pdfFiller.fillForm( sourcePDF, outputPDF, data, function(err) { if (err) throw err; console.log("In callback (we're done)."); }); ```` This will take the test.pdf, fill the fields with the data values and create a complete filled in PDF (test_complete.pdf) #### 2. Generate FDF from PDF ````javascript var pdfFiller = require('pdffiller'); var sourcePDF = "test/test.pdf"; pdfFiller.getFdf( sourcePDF, function(err, fdf) { if (err) throw err; console.log(fdf); }); ```` This will print out: ````'%FDF-1.2%âãÏÓ 1 0 obj << /FDF << /Fields [<< /V() /T(first_name) >><< /V() /T(last_name) >><< /V() /T(date) >><< /V() /T(football) >><< /V() /T(baseball) >><< /V() /T(basketball) >><< /V() /T(nascar) >><< /V() /T(hockey) >>] >> >> endobj trailer << /Root 1 0 R >> %%EOF '```` #### 3. Query PDF for form fields ````javascript var pdfFiller = require('pdffiller'), sourcePDF = "test/test.pdf", FDF_data, destinationPDF = "test/test_complete.pdf"; pdfFiller.getFormFields( sourcePDF, function(err, formFields) { if (err) throw err; console.log(formFields); }); ```` This will print out: ``` [ { fieldType: 'Text', fieldName: 'first_name', fieldFlags: '0', fieldJustification: 'Left' }, { fieldType: 'Text', fieldName: 'last_name', fieldFlags: '0', fieldJustification: 'Left' }, { fieldType: 'Text', fieldName: 'date', fieldFlags: '0', fieldJustification: 'Left' }, { fieldType: 'Button', fieldName: 'football', fieldFlags: '0', fieldJustification: 'Left', fieldStateOption: 'Yes' }, { fieldType: 'Button', fieldName: 'baseball', fieldFlags: '0', fieldJustification: 'Left', fieldStateOption: 'Yes' }, { fieldType: 'Button', fieldName: 'basketball', fieldFlags: '0', fieldJustification: 'Left', fieldStateOption: 'Yes' }, { fieldType: 'Button', fieldName: 'nascar', fieldFlags: '0', fieldJustification: 'Left', fieldStateOption: 'Yes' }, { fieldType: 'Button', fieldName: 'hockey', fieldFlags: '0', fieldJustification: 'Left', fieldStateOption: 'Yes' } ]; ```

About

Take an existing PDF Form and data and PDF Filler will create a new PDF with all given fields populated.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%