PDF Editing Issues

How to Pass PDF Form Data in a Submit URL and Parse XFDF

Tauseeq MagsiTauseeq Magsi Oct 28, 2026 869 views

Question details

The user wants to submit a PDF form as XFDF to a PHP backend script while appending a specific entered form field, such as an email address, directly to the destination URL.

How to Pass PDF Form Data in a Submit URL and Parse XFDF
Product
PDF
Device & OS
not provided
Scenario
Developing an interactive PDF form that submits user data to a server for automated workflows, requiring specific fields to be passed as GET parameters.
Observed behavior
The goal is to dynamically extract the value of the email field and concatenate it to the submission URL before triggering the XFDF data export.
Before you start

Ensure that your PDF viewer supports JavaScript execution for interactive forms and that you have backend access to the target PHP script to process the incoming XFDF payload.

Solution 1Recommended

Use Acrobat JavaScript to Build Dynamic Submit URLs

Add a custom JavaScript action to your form's Submit button to extract the desired field value and dynamically append it to the submission URL.

By utilizing the submitForm method in PDF Document JavaScript, you can construct a dynamic URL based on real-time user input. This allows you to send specific fields as URL parameters (GET request) while submitting the rest of the form data securely as XFDF.

1
Access Button Properties

Open your PDF form in edit mode, right-click the target 'Submit' button, and select Properties from the context menu.

2
Add a JavaScript Action

Navigate to the Actions tab. Under the 'Select Action' dropdown, choose 'Run a JavaScript' and click the 'Add' button to open the script editor.

3
Enter the Submission Script

Input the script to build your URL. For example: this.submitForm({ cURL: "https://www.yourdomain.com/process.php?email=" + this.getField("Email").valueAsString, cSubmitAs: "XFDF" });

4
Save and Test

Click OK to apply the script, close the properties window, and save your PDF. Test the button by filling out the email field and verifying that the data is sent properly to your PHP script.

Use Acrobat JavaScript to Build Dynamic Submit URLs
Field Name Matching: Ensure that the field name referenced in the getField method (e.g., "Email") matches the exact spelling and casing of the actual text field in your PDF document.
Powerful PDF Editor

Create and Manage Interactive PDF Forms with WPS PDF

WPS Office provides a comprehensive suite of PDF editing tools that allow you to seamlessly design interactive forms, insert action buttons, and configure form submissions with ease.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document using the WPS PDF viewer.
  2. 2. Navigate to the Form Tab: Click on the 'Form' tab in the top ribbon to access the interactive form controls.
  3. 3. Insert a Push Button: Select the 'Push Button' tool and drag it onto your document page to create a submit button.
  4. 4. Configure Button Actions: Double-click the button to open its Properties. Go to the Actions tab to set up your form submission preferences or apply custom actions.
Intuitive tools for adding text fields, checkboxes, and interactive push buttons.Fully compatible with standard Microsoft Office formats and Adobe Acrobat PDF forms.Lightweight architecture ensures fast loading and processing of complex form data.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF submit button not passing the data to the URL?

This commonly happens if JavaScript is disabled in the user's PDF viewer or if there is a syntax error in your script. Verify that 'cSubmitAs' is specified correctly and that the target field name exists.

Can I parse the XFDF data directly in a PHP script?

Yes, XFDF is an XML-based format. In your PHP backend, you can read the raw POST data using file_get_contents('php://input') and parse the XML string using PHP's SimpleXML or DOMDocument libraries.

How do I handle URL encoding for user inputs like email addresses?

When appending user input to a URL via JavaScript, it is highly recommended to wrap the field value in the encodeURIComponent() function. This ensures that special characters such as '@' and spaces are safely transmitted.