pdf form preview

Form fields are one of the integral components when dealing with customer data and it becomes easy to distribute the PDF Acro forms with users so that they can fill the forms with data of their choice and send it back. We are familiar that a variety of form fields can be used but among all these, TextBox, CheckBox, RadioButton, and ComboBoxes are very common. So, once the data has been filled in Acro forms, we parse the form fields at the back office to extract data from them and save them into FDF, XML, or directly into databases.

Though all the operations including PDF forms creation, form fields addition, form fields update activity can be performed manually, when dealing with a huge set of documents, the manual operation does not seem to be feasible because its time consuming and error-prone due to manual handling of data. So automatic routines through programming language can be a viable solution. Therefore, when creating a program, we get an option to either to use an on-premises solution/API which can help us to accomplish all the requirements or, use cloud-hosted REST APIs to parse the form fields.

REST API Benefits

The RESTful APIs get a leap here because you do not need to manually keep track of all API versions. Also, you do not need to keep your system updated with API versions and do not need to worry about compatibility issues of the APIs with a certain programming language, etc. Therefore, we present Aspose.PDF Cloud SDK for Java which provides the capabilities to create, manipulate as well as transform PDF documents to other supported file formats. The Java SDK is developed on top of Aspose.PDF Cloud REST APIs which can easily be accessed using cURL commands and the SDKs are developed to facilitate our customers using a particular programming language. In this blog, we are going to shed some light on how to parse different form fields

Read, Add or update TextBox fields

The API offers three ways to read information associated with TextBox fields.

API Type Description Swagger Link
/pdf/{name}/fields/textbox GET Read document TextBox fields GetDocumentTextBoxFields
/pdf/{name}/page/{pageNumber}/fields/textbox GET Read document TextBox fields for a give page GetPageTextBoxFields
/pdf/{name}/fields/textbox/{fieldName} GET Read document TextBox fields by a field name GetTextBoxField

cURL command to read TextBox fields

Since the files are stored in your personal cloud storage, so you need to first generate a JWT authentication token which requires your personalized Client ID and Client Secret.

curl -v "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/textbox" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"

Sample FormDataTextBox.pdf used in above example.


Parse CheckBox form fields

When dealing with CheckBoxes, the API also provides the capabilities to read CheckBox values, add a new checkbox or update the properties associated with an existing checkbox on PDF form.

cURL command to read CheckBox on page 1

curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/page/1/fields/checkbox" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"

CURL command to update CheckBox on Page 1

curl -X PUT "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/checkbox/Check%20Box1" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"Links\": [ { \"Href\": \"string\", \"Rel\": \"string\", \"Type\": \"string\", \"Title\": \"string\" } ], \"PartialName\": \"Aspose CheckBox\", \"FullName\": \"Aspose CheckBox\", \"Rect\": { \"LLX\": 88.3573, \"LLY\": 687.617, \"URX\": 97.0198, \"URY\": 695.413 }, \"Value\": \"null\", \"PageIndex\": 1, \"Height\": 12, \"Width\": 12, \"ZIndex\": 0, \"IsGroup\": false, \"IsSharedField\": true, \"Flags\": [ \"Default\" ], \"Color\": { \"A\": 0, \"R\": 150, \"G\": 120, \"B\": 0 }, \"Contents\": \"Field Updated\", \"Margin\": { \"Left\": 0, \"Right\": 0, \"Top\": 0, \"Bottom\": 0 }, \"Highlighting\": \"None\", \"HorizontalAlignment\": \"Left\", \"VerticalAlignment\": \"Center\", \"Border\": { \"Width\": 1, \"EffectIntensity\": 1, \"Style\": \"Solid\", \"Effect\": \"None\", \"Dash\": { \"On\": 1, \"Off\": 2 }, \"Color\": { \"A\": 255, \"R\": 120, \"G\": 120, \"B\": 0 } }, \"AllowedStates\": [ \"Yes\",\"Off\" ], \"Style\": \"Circle\", \"ActiveState\": \"On\", \"Checked\": true, \"ExportValue\": \"Yes\"}"

Request URL



Once the command/code is executed, the properties associated with checkbox 1 field are updated as shown in image below.

Preview of updated checkbox field

Image 1:- Preview of updated checkbox 1 using cURL command

Add or update RadioButton fields

Similar to TextBox and CheckBox fields, the Cloud SDK also provides the capabilities to read and update RadioButton fields on PDF documents.

cURL command to read RadioButton fields on PDF document

curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/radiobutton" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"

Request URL


Manipulate ComboBox form fields

Notice that the ComboBox manipulation becomes very handy with the help of Aspose.PDF Cloud SDK for Java. You get the option to read existing ComboBox fields on the document, add a new ComboBox field or update an existing ComboBox.

cURL command to read all ComboBox fields

curl -X GET "https://api.aspose.cloud/v3.0/pdf/FormDataTextBox.pdf/fields/combobox" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"

Request URL



As explained in the article above, the Form fields processing has become quite easy with the help of Cloud APIs. You may consider going through a related blog Form Parser | Form Recognizer | PDF Filling | Automate form processing with REST Web API