Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brianpursley/pdf-filler
A PDF filler web service based on Apache PDFBox
https://github.com/brianpursley/pdf-filler
Last synced: about 1 month ago
JSON representation
A PDF filler web service based on Apache PDFBox
- Host: GitHub
- URL: https://github.com/brianpursley/pdf-filler
- Owner: brianpursley
- License: apache-2.0
- Created: 2020-06-24T20:32:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-06T00:03:30.000Z (over 2 years ago)
- Last Synced: 2023-03-21T18:53:21.212Z (almost 2 years ago)
- Language: Java
- Size: 370 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a simple web service based on [Apache PDFBox](https://pdfbox.apache.org/), that lets you generate filled PDF forms using a set of values you post to the endpoint.
# Usage
The service provides two endpoints `/` and `/template`.
`/template` generates an example payload for the given fillable PDF.
For example, to generate a template for an [IRS W-9 form](https://www.irs.gov/pub/irs-prior/fw9--2018.pdf), you can make this request and pipe the output through [jq](https://github.com/jqlang/jq):
```shell
curl --request POST \
--url http://localhost:8080/template \
--header 'content-type: application/json' \
--data '{
"url": "https://www.irs.gov/pub/irs-prior/fw9--2018.pdf"
}' | jq
```The response is a template containing the URL along with the fields and their default values, like this:
```json
{
"url": "https://www.irs.gov/pub/irs-prior/fw9--2018.pdf",
"values": {
"topmostSubform[0].Page1[0].f1_1[0]": "",
"topmostSubform[0].Page1[0].f1_2[0]": "",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[0]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[1]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[2]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[3]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[4]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[5]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].f1_3[0]": "",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[6]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].f1_4[0]": "",
"topmostSubform[0].Page1[0].Exemptions[0].f1_5[0]": "",
"topmostSubform[0].Page1[0].Exemptions[0].f1_6[0]": "",
"topmostSubform[0].Page1[0].Address[0].f1_7[0]": "",
"topmostSubform[0].Page1[0].Address[0].f1_8[0]": "",
"topmostSubform[0].Page1[0].f1_9[0]": "",
"topmostSubform[0].Page1[0].f1_10[0]": "",
"topmostSubform[0].Page1[0].SSN[0].f1_11[0]": "",
"topmostSubform[0].Page1[0].SSN[0].f1_12[0]": "",
"topmostSubform[0].Page1[0].SSN[0].f1_13[0]": "",
"topmostSubform[0].Page1[0].EmployerID[0].f1_14[0]": "",
"topmostSubform[0].Page1[0].EmployerID[0].f1_15[0]": ""
}
}
```Once you know the structure of the payload, you can generate a custom payload and post it to the `/` endpoint to generate a filled-in PDF, like this:
```shell
curl --request POST \
--url http://localhost:8080/ \
--output example.pdf \
--header 'content-type: application/json' \
--data '{
"url": "https://www.irs.gov/pub/irs-prior/fw9--2018.pdf",
"values": {
"topmostSubform[0].Page1[0].f1_1[0]": "Foo Bar",
"topmostSubform[0].Page1[0].f1_2[0]": "Baz LLC",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[0]": "1",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[1]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[2]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[3]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[4]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[5]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].f1_3[0]": "",
"topmostSubform[0].Page1[0].FederalClassification[0].c1_1[6]": "Off",
"topmostSubform[0].Page1[0].FederalClassification[0].f1_4[0]": "",
"topmostSubform[0].Page1[0].Exemptions[0].f1_5[0]": "",
"topmostSubform[0].Page1[0].Exemptions[0].f1_6[0]": "",
"topmostSubform[0].Page1[0].Address[0].f1_7[0]": "123 Fake Street",
"topmostSubform[0].Page1[0].Address[0].f1_8[0]": "Cincinnati, OH 45241",
"topmostSubform[0].Page1[0].f1_9[0]": "",
"topmostSubform[0].Page1[0].f1_10[0]": "",
"topmostSubform[0].Page1[0].SSN[0].f1_11[0]": "",
"topmostSubform[0].Page1[0].SSN[0].f1_12[0]": "",
"topmostSubform[0].Page1[0].SSN[0].f1_13[0]": "",
"topmostSubform[0].Page1[0].EmployerID[0].f1_14[0]": "12",
"topmostSubform[0].Page1[0].EmployerID[0].f1_15[0]": "3456789"
}
}'
```The response saved in `example.pdf` is a [filled-in PDF](https://github.com/brianpursley/pdf-filler/raw/master/examples/filled-w9.pdf):
![Filled W-9](https://github.com/brianpursley/pdf-filler/raw/master/examples/filled-w9.png)# Docker
You can run the service using the docker image like this:
```
docker run -p 8080:8080 brianpursley/pdf-filler:latest
```