Git Product home page Git Product logo

pdf-filler's Introduction

This is a simple web service based on Apache PDFBox, 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 and IRS W-9 form, you can make this request:

curl --request POST \
  --url http://localhost:8080/template \
  --header 'content-type: application/json' \
  --data '{
	"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
}'

The response is a template containing the URL along with the fields and their default values, like this:

{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.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:

curl --request POST \
  --url http://localhost:8080/ \
  --header 'content-type: application/json' \
  --data '{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.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 is a filled-in PDF: Filled W-9

Docker

You can run the service using the docker image like this:

docker run -p 8080:8080 brianpursley/pdf-filler:latest

pdf-filler's People

Contributors

brianpursley avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.