How to Add a Subject Line to a PDF Submission Button
Question details
The user wants to configure a PDF submission script to include a specific email subject line, but the generated email only shows the default file name instead of the designated subject variable.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form button that uses JavaScript to submit data via email with a dynamically set subject line.
- Observed behavior
- The subject variable is defined in the script but is not passed correctly to the mail function, causing the email to use the PDF file name as the subject instead.
Ensure you have access to the JavaScript console in your PDF editor to test the script execution and identify any syntax errors before distributing the form.
Pass the Subject Variable in the mailForm Method
Update the JavaScript attached to your submission button so that the mailForm method explicitly receives the custom subject variable using the object-literal syntax.
By default, if you do not explicitly pass the subject argument into the mail function, the email client will default to using the document's file name. Adjusting the parameters of the mailForm function guarantees the proper variables are utilized.
Open your PDF form in Edit mode, right-click the submission button, and select 'Properties'.
Navigate to the 'Actions' tab, ensure 'Run a JavaScript' is selected, and click the 'Edit' button to view your script.
Ensure your script defines the recipient and the subject correctly. For example: var email = this.getField("Email To:").value; var cSubLine = "Meeting Request Form";
Locate the submission command (e.g., this.mailForm(false, email);) and change it to the object-literal format: this.mailForm({bUI: false, cTo: email, cSubject: cSubLine});

Create and Submit PDF Forms Easily with WPS Office
If debugging complex JavaScript functions in Adobe Acrobat is too time-consuming, WPS Office provides an intuitive PDF editor that allows you to easily create interactive forms, add text fields, and configure submission buttons without coding.
- 1. Open your PDF in WPS Office: Launch WPS Office, navigate to the PDF tab, and open the form document you need to edit.
- 2. Access the Form Controls: Click on the 'Form' tab in the top navigation ribbon to reveal all available interactive form controls.
- 3. Add a Push Button: Select the 'Push Button' tool, draw it on your page, and right-click it to access 'Properties'.
- 4. Set the Submit Action: Under the Actions tab in Properties, choose 'Submit a form' to configure where and how the form data should be sent.

Frequently Asked Questions
Why does my PDF submission button generate an email with no subject?
This happens when the script creates a subject variable but never explicitly assigns it to the `cSubject` parameter within the `mailForm` function. Updating the function to include `cSubject: yourVariableName` will resolve the issue.
Can I submit a PDF form without the user seeing the email pop up?
Yes, you can attempt a silent submission by passing `bUI: false` in the JavaScript `mailForm` method. However, for security reasons, most modern PDF readers require this command to be executed from a privileged context, like a trusted folder-level function.
How do I test my PDF JavaScript code for errors?
You can open the JavaScript Console in your PDF editing software (such as Acrobat) before clicking your submission button. The console will display syntax errors, undefined variables, or runtime issues to help you debug the code.




