Submit and Save PDF Forms Using JavaScript

When you use the PSPDFKit for Web Server-Backed deployment option, whenever a form field is filled in, the new value is automatically sent and stored by PSPDFKit Server. The exact moment of when the changes are sent to Server can be controlled by changing the auto-save mode.

If you use Instant, whenever any of the connected clients fills in the form field, the change is automatically synchronized to all the other connected clients.

With PSPDFKit Server, you can also fill the form fields with values coming from any source — e.g. a database or your backend application — using Server’s forms API. For example, assuming there are form fields called firstNameField and lastNameField in the document, you can set their values using the following HTTP request:

curl -X POST http://localhost:5000/api/documents/your-document-id/form-field-values \
  -H "Content-Type: application/json" \
  -d '{
  "formFieldValues": [
    {
      "name": "firstNameField",
      "value": "John"
    },
    {
      "name": "lastNameField",
      "value": "Appleseed"
    }
  ]
}'
POST /api/documents/your-document-id/form-field-values HTTP/1.1
Content-Type: application/json

{
  "formFieldValues": [
    {
      "name": "firstNameField",
      "value": "John"
    },
    {
      "name": "lastNameField",
      "value": "Appleseed"
    }
  ]
}

After the request succeeds, any client opening that document from PSPDFKit Server will see that the form fields have these values. Moreover, any clients that are connected with Instant enabled will see the values update in real time.