Create QR Code Barcodes in Crystal Reports Version 8.5 or Older
QR Code Barcodes in Crystal Reports 8.5 or Older
- The following tutorial shows how to create QR Code barcodes in older versions of Crystal Reports.
- Crystal Reports 8.5 and older do not support fields and formula outputs longer than 254 characters.
- To encode a QR Code barcode, we must split the formula into multiple parts.
![](https://media.barcodewiz.com/images/0d9110e5-cddf-42c4-b482-dbc8d2a9d4a5-QR_crystall90_001.png)
Step 1. Add a new formula
- In Field Explorer click on the icon to create a new formula.
- Hint: If you do not see Field Explorer, choose it from Standard Toolbar (see screenshot).
![](https://media.barcodewiz.com/images/a6e62415-d5ef-47f3-b9b9-23dc628a9230-QR_CR_85_create_formula.png)
- Name the formula. Add "...part0" suffix at the end of the formula name.
![](https://media.barcodewiz.com/images/3c7df9c5-ead8-419b-99e2-1170650d417d-QR_CR_85_name_formula.png)
Step 2. Copy the formula text.
- Copy the contents of this text into the Formula Editor:
// Part number of the barcode. Always begins with 0.
local numberVar partNumber := 0;
// barcodeInputArray is the text you wish to encode in the QR Code. It is an array of strings.
// By using an array instead of a single string, we are able to enter data that's longer than the limit of 254 characters.
//
// You can use multiple strings (up to 254 characters each), which will be joined together:
// local stringVar array barcodeInputArray:= ["Hello World", " and Other Planets"]; // encodes: Hello World and Other Planets
//
// If your data is under 254 characters then simply use a single-item array, like this:
// local stringVar array barcodeInputArray:= ["Hello World"];
// or
// local stringVar array barcodeInputArray:= [{my_data_table.item_name}];
//
// If your data is a number or date, it must be converted to string using the ToText() function. For example:
// local stringVar array barcodeInputArray:= [ ToText({my_data_table.item_amount}, 0, "")];
local stringVar array barcodeInputArray := ["Hello World"];
// Minimum size of QR Code symbol.
// Valid sizes are 1-40, where size 1 equals 21x21 modules per side and size 40 equals 177x177.
// Note: Size of symbol will automatically increase if too small for the data.
numberVar symbolSize := 1;
// Error correction level allows a partially damaged barcode to be scanned successfully.
// Valid values are 1-4, representing levels of L, M, Q, and H.
numberVar errorCorrectionLevel := 1;
// Allows input of special characters in format ^000 where 000 is decimal ASCII code.
// For example, ABC^009123^013^010 encodes "ABC[TAB]123[CARRIAGE RETURN][LINE FEED]".
// To encode the actual caret ^, enter it twice: ^^
// To encode FNC1, enter: ^F1
booleanVar allowSpecialChars := true;
// Determines what type of QR Code barcode to create.
// Set fnc1Mode to 0 to create "regular" QR Code barcodes (default)
// Set fnc1Mode to 1 to create GS1-QR barcodes.
// GS1-QR barcodes require input to be in the format: "(NN)XXXXXX(NN)XXXXXXXXX",
// where NN is a 2, 3, or 4-digit AI and XXXXXX is alphanumeric data to be encoded.
numberVar fnc1Mode := 0;
// Thickness of quiet zone (space around barcode), in number of modules.
// Note: Minimum quiet zone in QR Code is 4 modules. If you add a border (borderWidth > 0), ensure quietZoneWidth is 4 or larger.
// Default value is 0 (no quiet zone)
numberVar quietZoneWidth := 0;
// Thickness of border around barcode, in number of modules.
// If using a border, ensure quietZoneWidth is 1 or larger.
numberVar borderWidth := 0;
// Character encoding of higher ASCII values (above 127).
// For example: UTF-8 | ISO-8859-1 | ISO-8859-3 | ISO-2022-JP-2
stringVar characterInputEncoding := "ISO-8859-1";
// Character encoding for data encoded in the Data Matrix symbol.
// The recommended setting is UTF-8, which is the default for the majority of barcode scanners.
// If you change the setting, be sure the scanner understands it.
stringVar characterOutputEncoding := "UTF-8";
local stringVar hex := "";
local stringVar xvals := "0123456789ABCDEF";
local stringVar array hexStringsArray := [""];
local numberVar j;
for j := 1 to Count(barcodeInputArray) do
(
local numberVar strLen := Length(barcodeInputArray[j]);
local numberVar i;
For i := 1 to strLen Do
(
local numberVar num := Asc(Mid(barcodeInputArray[j], i, 1));
local numberVar first := Remainder( num, 256);
hex := hex + Mid(xvals, Int(first/16) + 1, 1) + Mid(xvals, Remainder(first, 16) + 1, 1);
if Length(hex) >= 254 then
(
ReDim Preserve hexStringsArray[Count(hexStringsArray)+1];
hexStringsArray[Count(hexStringsArray)] := hex;
hex := "";
);
);
);
if Length(hex) > 0 then
(
ReDim Preserve hexStringsArray[Count(hexStringsArray)+1];
hexStringsArray[Count(hexStringsArray)] := hex;
);
QrCodeEncodeFromHexArray(partNumber, hexStringsArray, symbolSize, errorCorrectionLevel, allowSpecialChars,
fnc1Mode, quietZoneWidth, borderWidth, characterInputEncoding, characterOutputEncoding);
Step 3. Edit the contents of the formula
- Replace "Hello World..." with your own data.
- Set other properties (Quiet Zone, Error Correction, etc) now as well.
![](https://media.barcodewiz.com/images/9db911d7-badd-4be2-8624-95f236a85af1-QR_CR_85_edit_formula.png)
Step 4. Create Copies of Formula
- Create two exact copies of the formula we created in step 3. Add the suffix part1 and part2 to formula names, correspondingly.
![](https://media.barcodewiz.com/images/2e9f540c-d6ad-40ee-b375-ae04358e4428-QR_CR_85_copy_formula.png)
Step 5. Edit partNumber
- Set partNumber to 1 in formula qrcode_part1
- Set partNumber to 2 in formula qrcode_part2
![](https://media.barcodewiz.com/images/a555e2ba-cb2d-4ce6-bee6-d0fb9135c125-QR_CR_85_partnumber.png)
Step 6. Insert a Text Object
- Insert a Text Object into your report.
![](https://media.barcodewiz.com/images/f2406325-4a2a-4d72-94ff-5df93a562019-QR_CR_85_insert_text.png)
Step 7. Add formulas to Text Object
- Drag all three formulas from Field Explorer to the Text Object.
![](https://media.barcodewiz.com/images/e1b0d6db-2c94-4640-9afb-5995360f1f86-QR_CR_85_drag_formulas.png)
Step 8. Set font properties
- Change the font to: BCW_QR and set the point size.
NOTE: For smaller barcodes, you can set the point size as low as 2pt
![Select BCW_QR as a font and the size of 6](https://media.barcodewiz.com/images/68c1f407-fef3-4245-9c29-252fb302aca2-QR_crystall90_008.png)
Step 9. Ensure the text object grows (if necessary
- Right-click on inserted formula and select Format Text...
![Select "Format Text" to enter the form, where further customization of a text field is possible](https://media.barcodewiz.com/images/09249f50-1317-4569-a16a-7184bb049060-QR_crystall90_009.png)
- Select Can Grow on the Common tab.
![Select "Can Grow" so that text box's height could be automatically adjusted](https://media.barcodewiz.com/images/47dd1370-9620-4d3c-bcb9-c9ba590763d7-QR_crystall90_010.png)
Finish the report
- Click on Preview to see the results.
![](https://media.barcodewiz.com/images/2ef0a13e-f397-4fdd-a335-af65e4fa2e9f-QR_CR_85_results.png)