How to Automatically Populate PDF Metadata from Form Fields
Question details
The user needs to automatically copy data entered into specific PDF form fields directly into the PDF document's Title metadata.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or managing interactive PDF forms where document metadata needs to reflect the entered form data dynamically.
- Observed behavior
- The document's Title metadata updates automatically based on the values typed into the Name, City, and State form fields.
Ensure you have a professional PDF editing tool that supports JavaScript integration and interactive form field properties. Save a backup of your original PDF form before adding or testing any document-level scripts.
Use JavaScript to Update Document Metadata
Attach a custom JavaScript action to a form button or field event to dynamically update the PDF metadata based on user input.
By using a document-level script or attaching a script to a specific trigger like a Submit button, you can read values from your form fields and write them directly into the PDF's properties.
Open your PDF form in a professional PDF editor with form editing capabilities, and enter the Form Editing mode.
Right-click the field or button that will trigger the metadata update, then select 'Properties'.
Navigate to the 'Actions' tab, select 'Run a JavaScript' from the 'Select Action' dropdown, and click the 'Add' button.
Enter the following script into the editor: this.info.Title = this.getField('Name').valueAsString + ', ' + this.getField('City').valueAsString + ', ' + this.getField('State').valueAsString;
Click 'OK' to save the script, exit form editing mode, and test the form by filling in the Name, City, and State fields to see if the metadata updates.

Edit and Manage PDF Forms with WPS PDF
WPS Office includes a powerful PDF editor that allows you to fill out interactive forms, edit PDF content, and manage document properties with ease. It's a lightweight, all-in-one solution for handling documents across different formats.
- 1. Install WPS Office: Download and install WPS Office on your device.
- 2. Open the PDF: Open your PDF file using the WPS PDF tool.
- 3. Fill out forms: Use the 'Form' tab to interact with or fill out form fields easily.
- 4. Check metadata: Go to 'Menu' > 'Document Properties' to view or edit metadata manually.

Frequently Asked Questions
Can I update other metadata fields like Author or Subject using JavaScript?
Yes, you can update other metadata fields by modifying the script. For example, use 'this.info.Author' or 'this.info.Subject' instead of 'this.info.Title' to target those specific document properties.
Why isn't the metadata updating immediately when I type?
If the script is attached to a button or a document save action, it will only execute when that action occurs. To update immediately, you need to attach the script to the 'On Blur' event of the specific form fields.
Is JavaScript supported in all PDF viewers?
No, basic PDF viewers, such as those built into web browsers, often do not support JavaScript execution. Users need to open the form in a fully-featured PDF reader or editor for the script to run properly.
How do I check if the metadata has been updated?
You can check the document's metadata by going to 'Menu' > 'Document Properties' or 'File' > 'Properties' in your PDF viewer and looking at the 'Description' tab where the Title, Author, and Subject are displayed.




