Adding Linear Barcodes In Crystal Reports Using UFL

The Crystal Reports UFL is free to use in conjunction with our barcode fonts. This Crystal Reports UFL is bundled with Fontware products (Windows version only). It is a component of Morovia Font Tools for Linear Barcode Fonts, which can be downloaded and upgraded separately. The Crystal Report UFL DLL provides encoding functions for the following barcode formats: Code 39, UPC-A, UPC-E, EAN-13, EAN-8, Code 93, Code128, EAN-128, Codabar, POSTNET, Royal Mail, and Interleaved 2 of 5. The UFL for two dimensional barcodes are included in 2D Fontware packages.

Prerequisites

  • Crystal Reports 6.0 and above

  • Morovia Linear Barcode Fonts

Crystal Reports UFL (User Function Library) provides a way to expose external functionality to Crystal Reports. Once installed, these functions can be used as if they are native functions. On the other side, the DLL must be installed and registered properly on every computer that your report will run, including computers from which you view the report through a Crystal Reports ActiveX control. Therefore, if the report is going to be distributed to and viewed on multiple computers, a better solution would be to create PDF documents with barcode fonts embedded.

A Tutorial

In the following tutorial we will start with a blank report. In the report we created several database fields. Now we want to add a barcode field which encodes shipping ID. We choose Code128C as the barcode format.

  1. First switch to the design view of the report. This can be done by selecting View | Design or by pressing CTRL+D.

  2. Now choose View | Field 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 field. In our case we simply call it barcode. You can also use any names compatible with your naming convention.

  5. Click on Use Editor button. The Formula Editor pops up. Find Morovia barcode functions under the Additional Functions | Visual Basic UFLs section. If you can not find such an item, most likely you installed the Font tool without closing Crystal Report. In this case restart Crystal Report and repeat the steps above.

  6. Select the appropriate barcode function (in our case is MoroviaBarcodeCode128C), double click it to make it appear in the bottom panel. Move the cursor between parentheses. Enter the data field you want to encode. In our case, we put {Sheet1_.CustomerID} because that field is what we want to present in barcode form. Note that this field needs to be a text string. You can use Crystal Reports function ToText to convert other format into text string.

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

  8. Drag the new field from Field Explorer to anywhere you want to place in the report.

  9. Right click on this new field to pop up Format Editor, and select Font tab. Use this page to change the font name and size so the barcode created fit the size requirement. In our case, we use MRV Code128CSA and 12 points font size. Click on OK to dismiss the dialog.

  10. Click on the Preview tab, barcodes should appear on th report. We have successfully build a report with barcode in minutes! Note that this tutorial uses the trial version of Code128 Fontware, so the second barcode contains a demo image. This limitation will go away in the full version.

Distributing UFL, Fonts with Your Report Application

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

License

You need a developer license to distribute fonts and UFL DLL designed by Morovia Corporation.

File List

There are three runtime files that need to be included in the installer:

  1. Morovia Barcode Font Files. The font files can be located at Fontware folder under Morovia directory.

  2. Morovia Crystal UFL. This file contains all the Morovia barcode functions and can be found under Morovia Font Tools directory (c:\program files\common files\MoroviaFontTools). Note that you must register the COM object in order to use it. The command line for registration is regsvr32 crufMorovia.dll.

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

Barcode Function Prototypes

The UFL provided implements all the functions listed in the Font Tools page. To save the space we will not list them in this page. They are very easy to use and remember. To conform to the Crystal Reports requirements, all UFL functions begin with MoroviaBarcode. For example, the function EAN13 listed in Font Tools page is available as MoroviaBarcodeEAN13. All functions take one single parameter which is the data to be encoded.