package
3.29.0+incompatible
Repository: https://github.com/unidoc/unidoc-examples.git
Documentation: pkg.go.dev

# README

PDF Forms

Forms and fields in PDF enables creating interactive forms as well as on the client side, filling in and submitting forms.

Examples

Use cases

  1. Conveniently export form data as JSON to file:
$ ./bin/pdf_form_fill_json example.pdf > fields.json
[DEBUG]  parser.go:747 Pdf version 1.6

Contents of fields.json

[
    {
        "name": "HIGH SCHOOL DIPLOMA",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "TRADE CERTIFICATE",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "COLLEGE NO DEGREE",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "PHD",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "OTHER DOCTORATE",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "ASSOCIATES DEGREE",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "MASTERS DEGREE",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "PROFESSIONAL DEGREE",
        "value": "Off",
        "options": [
            "Off",
            "On"
        ]
    },
    {
        "name": "STATE",
        "value": "WI"
    },
    {
        "name": "ZIP",
        "value": "30231"
    },
    {
        "name": "Name_Last",
        "value": "Johnsson"
    },
    {
        "name": "Name_First",
        "value": "John"
    },
    {
        "name": "Name_Middle",
        "value": "K."
    },
]
  1. Edit fields data, simply by altering the values in the JSON file.

  2. Import as JSON back and write out as flattened output file.

$ ./bin/pdf_form_fill_json ~/wh/Documents/UniDoc/bench/forms/interactiveform_filled.pdf fdata.json filled.pdf

The output filled.pdf is flattened so that it is no longer editable.