How to Create a QR Code from Two PDF Form Fields
Question details
The user needs to generate a dynamic QR code in a PDF form that concatenates the values of a BARCODE field and an SN (serial number) field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating advanced interactive PDF forms where a single QR code must encode combined data from multiple separate input fields.
- Observed behavior
- The desired outcome is a QR code field that automatically updates its encoded value to match a custom string format derived from two other specific form fields.
Ensure your PDF editor supports JavaScript for form fields and that both the 'BARCODE' and 'SN' text fields already exist in your document with these exact names.
Use a Custom JavaScript Calculation
Use this method to dynamically concatenate the values of two text fields and populate a QR code field.
By using a simple JavaScript calculation, you can tell the QR code field to read the values of other fields, combine them with an underscore, and generate the corresponding QR image automatically.
Right-click on your QR code form field and select 'Properties' from the context menu.
In the Properties window, click on the 'Calculate' tab to set up a custom calculation.
Select 'Custom calculation script' and enter the following code: event.value = this.getField("BARCODE").valueAsString + "_" + this.getField("SN").valueAsString;
Click 'OK' to save the script, close the properties window, and test the form by entering values into the BARCODE and SN fields.

Create and Manage Interactive PDF Forms with WPS PDF
WPS Office provides robust PDF editing capabilities, allowing you to easily manage form fields, edit content, and interact with complex PDF documents without any hassle.
- 1. Open your PDF: Launch WPS Office and open the PDF form you wish to edit or fill.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form editing options.
- 3. Manage Fields: Select the interactive fields to input data, or use the editing tools to modify the layout.
- 4. Save and Export: Once your form is filled or edited, save the document or export it directly to secure your data.

Frequently Asked Questions
Why is my QR code not updating automatically?
Ensure that 'Automatically calculate field values' is enabled in your PDF editor's preferences. Also, double-check your JavaScript for any typos in the field names.
Can I combine more than two fields into a single QR code?
Yes. You can chain additional fields in your JavaScript using the '+' operator. For example: + '_' + this.getField('EXTRA').valueAsString;.
What happens if one of the referenced fields is empty?
If a field is empty, the valueAsString property returns an empty string. The QR code will generate with just the underscore and the remaining filled data.
Can I use a fixed text string instead of a dynamic field?
Yes. If the barcode or serial number is fixed, you can replace the this.getField() reference in the script with a static string enclosed in quotes, such as '8888888888888' + '_' + this.getField('SN').valueAsString;.




