PDF Editing Issues

How to Create a QR Code from Two PDF Form Fields

Steven ParkerSteven Parker Nov 2, 2026 869 views

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.

How to Create a QR Code from Two PDF Form Fields
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.
Before you start

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.

Solution 1Recommended

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.

1
Open Field Properties

Right-click on your QR code form field and select 'Properties' from the context menu.

2
Navigate to the Calculate Tab

In the Properties window, click on the 'Calculate' tab to set up a custom calculation.

3
Enter the JavaScript Code

Select 'Custom calculation script' and enter the following code: event.value = this.getField("BARCODE").valueAsString + "_" + this.getField("SN").valueAsString;

4
Apply and Test

Click 'OK' to save the script, close the properties window, and test the form by entering values into the BARCODE and SN fields.

Use a Custom JavaScript Calculation
Case Sensitivity: Ensure that the field names inside the getField() function exactly match the names of your form fields, as JavaScript is highly case-sensitive.
Edit PDF Forms Easily

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. 1. Open your PDF: Launch WPS Office and open the PDF form you wish to edit or fill.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form editing options.
  3. 3. Manage Fields: Select the interactive fields to input data, or use the editing tools to modify the layout.
  4. 4. Save and Export: Once your form is filled or edited, save the document or export it directly to secure your data.
Easily insert, edit, and fill PDF form fieldsHighly compatible with Adobe Acrobat PDF forms and standard PDF formatsLightweight, fast, and user-friendly interfaceIncludes comprehensive tools for PDF annotation and conversion
microsoft office alternative - wps office

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;.