GlobalForms can draw QR codes and barcodes for you. Show one on a form, for example a QR code that links to a web page, or a Code 128 barcode of an invoice number that staff can scan later.
The barcode address
Every GlobalForms server creates barcode images at /barcode/. Add the barcode type and the text to encode to the address, and it returns a PNG image:
https://forms.example.com/barcode/?bcid=qrcode&text=Hello%20World
Open the address in a browser to try different settings before you add a code to a form. Keep the slash after barcode; without it the image doesn't load.
Signing in isn't needed to load a barcode image, so codes appear on public forms too.
Settings
|
Setting |
What it does |
Example |
|---|---|---|
|
|
Required. The barcode type. See the table below. |
|
|
|
Required. The value to encode, URL-encoded (see Encoding the text). |
|
|
|
Size of the image. Each step makes the code larger. Very large images are refused with the message "Image size over default limit". |
|
|
|
Bar height, in millimeters, for one-dimensional barcodes such as Code 128. |
|
|
|
Prints the value under a one-dimensional barcode. No value is needed. |
|
|
|
White space around the code. Scanners read codes more reliably with a margin. |
|
|
|
QR error correction: |
|
If a setting is wrong, the address returns a short error message instead of an image, for example when text is missing or the barcode type is unknown.
Barcode types
|
|
Barcode |
Typical use |
|---|---|---|
|
|
QR Code |
Web addresses and short text, scanned with a phone |
|
|
Code 128 |
Reference numbers with letters and digits |
|
|
Code 39 |
Older scanners and labels |
|
|
Data Matrix |
Small labels |
|
|
PDF417 |
IDs and longer text |
|
|
Aztec Code |
Tickets and boarding passes |
|
|
EAN-13, UPC-A |
Retail product numbers |
Many more types are available. They follow the names used by the open source BWIPP barcode library.
Encoding the text
The text is part of a web address, so characters such as spaces, &, #, +, % and / must be URL-encoded. For example, a space becomes %20 and & becomes %26. Text that isn't encoded is cut short or changed, and the code holds the wrong value.
The encoded value is sent to the server as part of the image address. Don't put passwords or other sensitive information in a barcode.
Show a fixed code on a form
Use this for a code that is the same for everyone, such as a link to your website.
-
Add an HTML Element component to the form.
-
In its Content, add an image whose address starts with
/barcode/:HTML<img alt="QR code for our website" src="/barcode/?bcid=qrcode&text=https%3A%2F%2Fwww.example.com&scale=4&paddingwidth=4&paddingheight=4"> -
Save the form and open it to check the code.
An address that starts with /barcode/ always uses the server the form is on, so you don't need to include the server name.
Show a code from a form field
To build the code from what the user enters, for example an invoice number, take the value from the form data. The code updates as the user types.
Simple values
If the field only ever contains letters, numbers, dashes and dots, put the field's property name in double braces in an HTML Element:
<img alt="Invoice barcode" src="/barcode/?bcid=code128&includetext&height=12&scale=2&text={{ data.invoiceNumber }}">
The value is inserted without URL encoding, so don't use this method for values that can contain spaces or other special characters. Placeholders like {{ data.invoiceNumber }} work in the HTML Element component, but not in the Content component.
Any value
For values that may contain spaces or special characters, such as names, addresses or web links, set the image address with a short script that encodes the value:
-
Add an HTML Element with an empty image that has an ID:
HTML<img id="invoiceQr" alt="Invoice QR code"> -
Add a Text Field and select Hidden on its Display tab.
-
On its Data tab, add this Calculated Value. Change
invoiceNumberto your field's property name, andinvoiceQrto the image's ID:JavaScriptvar img = document.getElementById('invoiceQr'); var url = '/barcode/?bcid=qrcode&scale=4&paddingwidth=4&paddingheight=4&text=' + encodeURIComponent(data.invoiceNumber || ''); if (img && img.getAttribute('src') !== url) { img.setAttribute('src', url); } value = url;
The hidden field saves the image address with the submission, which is harmless. See Rules and Scripting for more on calculated values.
Tips
-
Test every code with the scanner or phone that will read it, at the size it will be printed or shown.
-
Add padding around QR codes, and keep the text short. Shorter text gives a less dense code that scans more easily.
-
To change the size on screen without changing
scale, set a width on the image, for examplestyle="width:150px".