Adding PDF417 barcodes to Crystal Reports


Conceptually using two dimensional barcode fonts with Crystal Report is no different than using other fonts. In practice, there are a couple of issues need to work out. The major issue associated is the length limit imposed by Crystal Reports: no formula field can have more than 255 characters.

To add PDF417 barcodes to Crystal Report, you need to use Morovia 2D Fontware UFL. Native Crystal Reports formula is not supported.


The method described in this KB article applies on PDF417 Fontware version 3.x only. For version 4.0 and above, see PDF417 Fontware & Writer SDK 4 Reference Manual.

Installing UFL

We use Crystal Reports version 9 for tutorial. If you are working on an earlier version the steps outlined still apply. You are authorized to use the UFL provided by Morovia for free as long as you own a perpetual license. You are also allowed to distribute this UFL with your application with a developer license.

The PDF417 UFL component is included in every PDF417 Fontware package. There is no separate download of this UFL component. If you posses a valid license to any of 2D barcode font but can not locate this component, write to to request one.

The UFL functions are automatically available to Crystal Reports once the component is installed in your computer. The following functions are added to Crystal Reports:

Table 1. PDF417 UFL Functions

MoroviaPDF417Encode Encode the data into an array of barcode string separated by line feed and carriage return between two adjacent lines.

Both function takes a parameter called trunk_no. Because Crystal Reports do not allow any formula fields having more than 255 characters, you need to call multiple times of encoding functions to receive different trunks of the result. The trunk_no starts from 1. Each trunk holds 200 characters.

Working with Crystal Reports

In the following tutorial we will start with a blank report. In the report we created several database fields. We want to be able to encode the data field of a table.

  1. First we switch to the design view. This can be done by choosing ViewDesign (Ctrl+D)

  2. Now choose ViewField Explorer to have Field Explorer appear at the right side of the work space.

  3. We are now ready to add the barcode field. Right click the Formula Fields to have the context menu pop up. Choose New...

  4. Give a name to this new filed. In our case we simply call it barcode_trunk1.

  5. Click on the Use Editor button. The Formula Editor pops up. Find Morovia barcode functions under the Additional Functions+Visual Basic 2000 Functions section. If you can not find such an item, most likely you probably need to check your computer to see why the file is missing. Restart Crystal Report and repeat the steps above.

  6. Select the the function MoroviaPDF417Encode, double click it to make it appear in the bottom panel. Move the cursor in between the parentheses. Put the data field you want to encode. In our case, we put {TestData.Data} because that filed is what we want to present in barcode form. Note that this field must be a text string. You can use Crystal Reports function ToText to convert other format into text string. Move the cursor to the next field, and type 1.

  7. Dismiss the Formula Editor and return to the Field Explorer dialog.

  8. Based on the calculation from the GUI Encoder, we know that it takes about 700 characters for the result. Thus we need four trunks to hold all the barcode string. We repeat the steps above and add another formula field barcode_trunk2. Repeat the steps above to add fields barcode_trunk3 and barcode_trunk4.

  9. Add a text field to the report. You can do this by selecting the text field from toolbar the dragging it to the report.

  10. Click on the text field to select it. From the Field Explorer, drag and drop the formula field, barcode_trunk1 into the text field.

  11. Drag and drop barcode_trunk2 to the same text field. Crystal Reports puts {@barcode_trunk1}{@barcode_trunk2}{@barcode_trunk3}{barcode_trunk4} into the text field.

  12. Format the text field with MRV PDF417S font. To do this you can right click the text field and select format text... menu item.

  13. Click on the Preview tab. The barcodes should appear. We have successfully build a report with barcode in minutes! During the encoding process, a dialog pops up to remind you that you are using a trial version of the software, and each symbol contain additional text "DEMO". This limitation will go away once you purchase the retail version.

Distributing UFL, Fonts with Your Report

Once you finish the report design, you can distribute your report application with Crystal run time files, barcode fonts and the UFL library.


First you must obtain a valid license from Morovia Corporation. You can either purchase single user license for every computer you are going to install; or purchase a Corporate license if you have a large install base within your organization. If you want to distribute outside your company, a developer license must be obtained.

File List

There are four runtime files needs to be included in the installer:

  • Morovia Barcode Font Files. The font files can be located at Fontware folder under c:\program files\morovia directory.

  • Morovia 2D Barcode Fontware Crystal UFL. This file contains all the 2D barcode font encoder for Crystal Reports. This file is named cruflMrv2DSurrogate.dll, which can be found in system32 folder under Windows directory. Note that you must register the COM object in order to use it. The command line for registration is regsvr32 cruflMrv2DSurrogate.dll.

  • Morovia PDF417 Font Encoder (ActiveX). This dll is normally located at c:\program files\morovia\PDF417Fontware. Since it is an ActiveX, you need to register in the client machine before using it.

  • Crystal Runtime. The file name is U2lcom.dll. This file is required to work with COM UFLs.