How to Create a Dynamic PDF Submission URL Using a Form Field
Question details
The user needs to configure a PDF form so that the submission button sends the form data to a custom URL that changes dynamically based on the input of a specific form field.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where data needs to be routed to different server endpoints or folders based on user-specific inputs, such as their name or ID.
- Observed behavior
- Instead of using a standard fixed address for the PDF Submit Form action, the goal is to extract a field's value and append it to a base URL before executing the submission.
Ensure you have access to a professional PDF editor that supports JavaScript for form controls, and verify that your target server is configured to accept PDF data submissions.
Use JavaScript to Build and Execute a Dynamic Submission URL
By applying a custom JavaScript action to your form's submit button, you can extract the value from any text field and concatenate it with your base server URL to route the submission dynamically.
Standard 'Submit a form' actions in PDF editors only allow you to specify a fixed URL. To bypass this limitation, you can use Acrobat JavaScript's `this.submitForm()` method. This allows you to evaluate user input, validate it, and dynamically construct the destination URL before sending the data.
Open your PDF document in your PDF editor, navigate to the Form editing tools, and ensure you have a text field named 'Name' (or adjust the script to match your field's exact name).
Insert a 'Push Button' form field onto the page. This will act as your submit button.
Right-click the button, select 'Properties', and navigate to the 'Actions' tab. Choose 'Mouse Up' as the trigger and 'Run a JavaScript' as the action, then click 'Add'.
In the JavaScript editor window, enter the following script to read the field value and build the URL: var name = this.getField("Name").valueAsString; if (name == "") { app.alert("You must first enter your name before submitting the file."); } else { this.submitForm({cURL: "http://www.myserver.com/submitfolder/" + name, cSubmitAs: "PDF"}); }
Click 'OK' to save the script, close the properties dialog, and exit form editing mode. Type a value into the 'Name' field and click your button to test the dynamic submission.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides comprehensive PDF editing tools that allow you to seamlessly insert text fields, checkboxes, and interactive buttons. Easily build forms and manage PDF documents without the need for expensive software.
- 1. Open Your Document: Launch WPS Office and open the PDF file you wish to turn into an interactive form.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal all fillable form controls.
- 3. Add Fields and Buttons: Click on 'Text Field', 'Push Button', or other controls to place them on your document, then double-click them to configure their properties.
- 4. Save Your PDF: Once your form fields are configured, save the document to lock in your layout and share it with your users.

Frequently Asked Questions
What happens if the referenced form field is empty during submission?
If your JavaScript includes a validation check (like checking if the variable equals an empty string), the script will trigger an alert prompt to the user and halt the submission process until the required field is filled out.
Can I submit the form data as HTML instead of a complete PDF file?
Yes. In the `this.submitForm()` JavaScript method, you can modify the `cSubmitAs` parameter from 'PDF' to 'HTML'. This will send the form data as standard HTML form variables instead of transmitting the entire PDF document.
Will this dynamic submission script work in all PDF readers?
No, executing dynamic submissions via the `submitForm` method requires a PDF viewer that supports Acrobat JavaScript. While most professional desktop PDF editors support this, basic browser-based PDF readers or simple mobile viewers may ignore the script.




