This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
forked from pdffillerjs/pdffiller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
36 lines (36 loc) · 5.78 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"name": "pdffiller",
"version": "0.0.10",
"private": false,
"description": "Take an existing PDF Form and data and PDF Filler will create a new PDF with all given fields populated.",
"main": "index.js",
"scripts": {
"test": "node_modules/.bin/mocha test/test.js"
},
"keywords": [
"nodejs",
"pdftk",
"fdf",
"pdffiller",
"pdf"
],
"dependencies": {
"lodash": "~4.17.11",
"utf8-fdf-generator": "0.0.3"
},
"author": {
"name": "John Taylor and David Baldwynn"
},
"license": "MIT",
"readmeFilename": "README.md",
"gitHead": "dc344fd81d90d0434dcc253d9ee14e4328b680dd",
"readme": "PDF Filler (Node.js)\n======\n\nA node.js PDF form field data filler and FDF generator toolkit. This essentially is a wrapper around the PDF Toolkit library <a target=\"_blank\" href=\"http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/\">PDF ToolKit</a>.\n\nPDF Filler requires the PDF ToolKit which can be found here: <a target=\"_blank\" href=\"http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/\">PDF ToolKit</a>\n\n\n##Examples\n\n#### 1.Fill PDF with existing FDF Data\n````javascript\nvar pdfFiller = require( 'pdffiller' );\n\nvar sourcePDF = \"test/test.pdf\";\nvar destinationPDF = \"test/test_complete.pdf\";\n\nvar data = {\n \"last_name\" : \"John\",\n \"first_name\" : \"Doe\",\n \"date\" : \"Jan 1, 2013\",\n \"football\" : \"Off\",\n \"baseball\" : \"Yes\",\n \"basketball\" : \"Off\",\n \"hockey\" : \"Yes\",\n \"nascar\" : \"Off\"\n};\n\npdfFiller.fillForm( sourcePDF, destinationPDF, data, function(err) { \n if (err) throw err;\n console.log(\"In callback (we're done).\"); \n});\n\n````\n\nThis will take the test.pdf, fill the fields with the data values\nand create a complete filled in PDF (test_filled_in.pdf)\n\n\n#### 2. Generate FDF Template from PDF\n````javascript\nvar pdfFiller = require( 'pdffiller' );\n\nvar sourcePDF = \"test/test.pdf\";\n\nvar FDF_data = pdfFiller.generateFDFTemplate( sourcePDF, function(err, fdfData) { \n if (err) throw err;\n console.log(fdfData);\n});\n\n````\n\nThis will print out this \n```{\n \"last_name\" : \"\",\n \"first_name\" : \"\",\n \"date\" : \"\",\n \"football\" : \"\",\n \"baseball\" : \"\",\n \"basketball\" : \"\",\n \"hockey\" : \"\",\n \"nascar\" : \"\"\n};```\n\n#### 3. Generate FDF Template from PDF\n````javascript\nvar pdfFiller = require( 'pdffiller' );\n\nvar sourcePDF = \"test/test.pdf\";\n\nvar FDF_data = pdfFiller.generateFDFTemplate( sourcePDF, function(err, fdfData) { \n if (err) throw err;\n console.log(fdfData);\n});\n\n````\n\nThis will print out this \n```\n{\n \"last_name\" : \"\",\n \"first_name\" : \"\",\n \"date\" : \"\",\n \"football\" : \"\",\n \"baseball\" : \"\",\n \"basketball\" : \"\",\n \"hockey\" : \"\",\n \"nascar\" : \"\"\n};\n```\n\n#### 4. Map form fields to PDF fields\n````javascript\nvar pdfFiller = require( 'pdffiller' ),\n sourcePDF = \"test/test.pdf\",\n FDF_data,\n destinationPDF = \"test/test_complete.pdf\";\n\nvar conversionMap = {\n \"lastName\": \"last_name\",\n \"firstName\": \"first_name\",\n \"Date\": \"date\",\n \"lastName\": \"last_name\",\n \"footballField\": \"football\",\n \"bballField\": \"basketball\",\n \"baseballField\": \"baseball\",\n \"hockeyField\": \"hockey\",\n \"nascarField\": \"nascar\"\n};\n\nvar FormFields = {\n \"lastName\" : \"John\",\n \"firstName\" : \"Doe\",\n \"Date\" : \"Jan 1, 2013\",\n \"footballField\" : \"Off\",\n \"baseballField\" : \"Yes\",\n \"bballField\" : \"Off\",\n \"hockeyField\" : \"Yes\",\n \"nascarField\" : \"Off\"\n};\n\npdfFiller.mapForm2PDF( data, convMap, function(err, mappedFields) { \n if (err) throw err;\n\n console.log(mappedFields);\n});\n````\n\nThis will print out the object below.\n```{\n \"last_name\" : \"John\",\n \"first_name\" : \"Doe\",\n \"date\" : \"Jan 1, 2013\",\n \"football\" : \"Off\",\n \"baseball\" : \"Yes\",\n \"basketball\" : \"Off\",\n \"hockey\" : \"Yes\",\n \"nascar\" : \"Off\"\n};```\n\n#### 5. Convert fieldJson to FDF data\n````javascript\nvar pdfFiller = require( 'pdffiller' );\n\nvar sourcePDF = \"test/test.pdf\";\nvar fieldJson = [\n {\n \"title\" : \"last_name\",\n \"fieldfieldType\": \"Text\",\n \"fieldValue\": \"Doe\"\n },\n {\n \"title\" : \"first_name\",\n \"fieldfieldType\": \"Text\",\n \"fieldValue\": \"John\"\n },\n {\n \"title\" : \"date\",\n \"fieldType\": \"Text\",\n \"fieldValue\": \"Jan 1, 2013\"\n },\n {\n \"title\" : \"football\",\n \"fieldType\": \"Button\",\n \"fieldValue\": false\n },\n {\n \"title\" : \"baseball\",\n \"fieldType\": \"Button\",\n \"fieldValue\": true\n },\n {\n \"title\" : \"basketball\",\n \"fieldType\": \"Button\"\n \"fieldValue\": false\n },\n {\n \"title\" : \"hockey\",\n \"fieldType\": \"Button\"\n \"fieldValue\": true\n },\n {\n \"title\" : \"nascar\",\n \"fieldType\": \"Button\"\n \"fieldValue\": false\n }\n];\n\nvar FDFData = pdfFiller.convFieldJson2FDF( data );\nconsole.log(FDFData)\n````\n\nThis will print out this \n````\n{\n \"last_name\" : \"John\",\n \"first_name\" : \"Doe\",\n \"date\" : \"Jan 1, 2013\",\n \"football\" : \"Off\",\n \"baseball\" : \"Yes\",\n \"basketball\" : \"Off\",\n \"hockey\" : \"Yes\",\n \"nascar\" : \"Off\"\n};\n````\n",
"_id": "pdffiller@0.0.8",
"_shasum": "416c724b748a5e0caf494fb66b043d450b8a3b9a",
"_from": "whitef0x0/pdffiller",
"_resolved": "git://github.com/whitef0x0/pdffiller.git#dc344fd81d90d0434dcc253d9ee14e4328b680dd",
"devDependencies": {
"mocha": "~2.4.5",
"should": "~6.0.1"
}
}