A PDF processor written in Go.
View the Project on GitHub pdfcpu/pdfcpu
This command creates a JSON file containing a PDF form structure with optional data.
The resulting JSON payload contains the single element array forms
serving as a starting point for form filling.
The content of this element contains all form fields grouped by field type:
Have a look at some examples.
pdfcpu form export inFile [outFileJSON]
name | description | values |
---|---|---|
v(erbose) | turn on logging | |
vv | verbose logging | |
q(uiet) | quiet mode | |
-o(ffline) | disable http traffic | |
c(onf) | config dir | $path, disable |
opw | owner password | |
upw | user password | |
u(nit) | display unit | po(ints),in(ches),cm,mm |
name | description | required |
---|---|---|
inFile | PDF input file containing form | yes |
outFileJSON | JSON output file | no |
Export a form created with pdfcpu to JSON:
$ pdfcpu form export english.pdf
writing out.json...
$ cat out.json
{
"header": {
"source": "english.pdf",
"version": "pdfcpu v0.4.1",
"creation": "2023-03-04 20:22:17 CET",
"producer": "pdfcpu v0.4.1"
},
"forms": [
{
"textfield": [
{
"page": 1,
"id": "30",
"name": "firstName1",
"default": "Joe",
"value": "Jackie",
"multiline": false,
"locked": false
},
{
"page": 1,
"id": "31",
"name": "note1",
"value": "This is a sample text.\nThis is the next line.",
"multiline": true,
"locked": false
}
],
"datefield": [
{
"page": 1,
"id": "33",
"name": "dob1",
"format": "dd.mm.yyyy",
"default": "01.01.2000",
"value": "31.12.1999",
"locked": true
}
],
"checkbox": [
{
"page": 1,
"id": "34",
"name": "cb11",
"default": false,
"value": true,
"locked": false
},
],
"radiobuttongroup": [
{
"page": 1,
"id": "35",
"name": "gender1",
"options": [
"female",
"male",
"non-binary"
],
"default": "male",
"value": "non-binary",
"locked": false
}
],
"combobox": [
{
"page": 1,
"id": "36",
"name": "city12",
"editable": false,
"options": [
"London",
"San Francisco",
"Sidney"
],
"default": "San Francisco",
"value": "Sidney",
"locked": false
}
],
"listbox": [
{
"page": 1,
"id": "37",
"name": "city11",
"multi": true,
"options": [
"San Francisco",
"São Paulo",
"Vienna"
],
"defaults": [
"Vienna",
"São Paulo"
],
"values": [
"San Francisco",
"Vienna"
],
"locked": false
}
]
}
]
}