BarCodeWiz Logo

Data Matrix 2D Barcodes in Crystal Reports 8.5 or Older

Data Matrix Barcodes in Crystal Reports 8.5 or Older

  • The following tutorial shows how to create Data Matrix barcodes in Older versions of Crystal Reports.
  • Please note, Crystal Reports in versions 8.5 and older do not support fields with more than 254 characters. In order to encode a Data Matrix barcode one has to use a trick - add more fields and name them xxxxx_Part0, xxxxx_Part1, etc. 
Some finished Data Matrix barcodes

Step 1. Add a new formula

  • In Field Explorer right-click on "Formula" and select "New".
  • Hint: If you do not see Field Explorer, choose it from Standard Toolbar (see screenshot).
Right-click on "Formula" and select "New", to create a new formula

Name the formula. Remember to add "...PartX" suffix at the end of the formula name.

Enter the name for your formula

In our example, we created three copies of our field...

Drag all three formulas from Field Explorer to the Text Object

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.
numberVar partNumber := 0; 


  // This is the text you wish to encode. Replace "HELLO" with your own data.
  // For example: stringVar barcodeInput := {my_data_table.item_text}; 
  // 
  // If your data is a number or date, it must be converted to string using the ToText() function.
  // For example: stringVar barcodeInput := ToText( {my_data_table.item_text}, 0, ""); 
stringVar barcodeInput:=  "HELLO"; 

  // Minimum size of Data Matrix symbol.. Valid sizes are 1-30. 
  // Square sizes are 1-24 (size 1 equals 10x10 modules per side and size 24 equals 144x44).
  // Non-Square sizes are 25-30 (size 25 equals 8x18 modules, and size 30 equals 16x48).
  // Note: Size of symbol will automatically increase if too small for the data.
numberVar symbolSize := 1;              
  
  // Encoding mode for this Data Matrix symbol. Describes how to best encode the supplied text 
  // to achieve smallest symbol size.
  // Possible values are: Auto, Ascii, C40, Text, X12, Edifact, Base256
stringVar dataMatrixEncoding := "Auto";

  // 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 whether the symbol is a regular DataMatrix or a GS1-DataMatrix barcode.
  // Set IsGS1 to false to create "regular" DataMatrix barcodes (default).
  // Set IsGS1 to true to create GS1-DataMatrix barcodes.
  // GS1-DataMatrix 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.
booleanVar isGs1 := false;            

  // Thickness of quiet zone (space around barcode), in number of modules.
  // Note: Minimum quiet zone is 1 module. If you add a border (borderWidth > 0), ensure quietZoneWidth is 1 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 characterEncoding := "UTF-8";


DataMatrixEncode(partNumber, barcodeInput, symbolSize, dataMatrixEncoding, allowSpecialChars, 
                                            isGs1, quietZoneWidth, borderWidth, characterEncoding); 

 

 


Edit the contents of formulas

  • Please make sure the digits marked in yellow are properly numbered. Part 1 needs to have partNumber numbered as 1Part 2 needs to have partNumber numbered as 2.
  • All other variables which are being set in each field must be the same in each Part.
Edit all your formulas to obtain a valid Data Matrix barcode in versions 8.5 or older of Crystal Reports

Step 3. Add a barcode to the report

  • Insert Text Object into your report.
Insert Text Object into your report

  • Drag all three formulas from Field Explorer to the Text Object.
Drag all three formulas from Field Explorer to the Text Object

Step 4. Edit the text field

  • Change the font to: BCW_DM and set the point size.

NOTE:  For smaller barcodes, you can set the point size as low as 2pt

Change the font to BCW_DM and set the point size

  • Right-click and select Format Text...
 Select Format Text to edit all the details of your formula for Data Matrix barcode

  • Select Can Grow on the Common tab.
Select "Can Grow" so that text box's height could be automatically adjusted

That is it! The barcode is generated

... Click on Preview ... 

Preview of the finished report with Data Matrix barcodes in it