
Click
here to view the image in full size.
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 create DataMatrix barcodes in Crystal Report,
you need Morovia 2D Fontware UFL. Native
Crystal Reports formula is not supported.
Note: the method described in this article
are based on
Morovia DataMatrix Fontware 3.0.
The UFL library is not compatible with earlier
versions.
We use Crystal Reports version 9 for this 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 Datamatrix UFL component is included in DataMatrix
Fontware. 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
support@morovia.com 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:
|
Function |
Description |
|
MoroviaDataMatrixEncode |
Encode the
data into an array of barcode string
separated by line feed and carriage
return between two adjacent lines. |
|
MoroviaDataMatrixEncode2 |
Similiar
with MoroviaDataMatrixEncode function,
but offers more options. You can specify
the target size and line separator with
this function. |
Both function takes a parameter called
trunk_no. Because Crystal Reports do not allow
any forumla 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.
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.

- First we switch to the design view of the
report. This can be done by choosing View |
Design or by pressing Ctrl+D.
- Now choose View | Field Explorer to have
Field Explorer appear at the right side of the
work space.
- We are now ready to add the barcode field.
Right click the Formula Fields to have the context
menu pop up. Choose New...
- Give a name to this new filed. In our case
we simply call it barcode_trunk1. You can also use
any names compatible with your naming convention.
- Click on the Use Editor button. The Formula
Editor pops up. Find Morovia barcode functions
under the "Additional 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.

- Select the the function
MoroviaDataMatrixEncode, double
click it to make it appear in the bottom panel.
Move the cursor in between the parenthesis.
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.
- Dismiss the Formula Editor and return to
the Field Explorer dialog.
- Based on the calculation from the GUI
Encoder, we know that it takes about 300
characters for the result. Thus we need two
trunks to hold all the barcode string. We
repeat the steps above and add another
formula field barcode_trunk2.
- Add a text field to the report. You can
do this by selecting the text field from
toolbar the dragging it to the report.
- Click on the text field to select it.
From the Field Explorer, drag and drop
Formula Field, barcode_trunk1 into the text
field.
- Drag and drop barcode_trunk2 to the same
text field. Crystal Reports puts
{@barcode_trunk1}{@barcode_trunk2} into the
text field.
- Fromat the text field with "MRV
DataMatrix" font. To do this you can right
click the text field and select format
text... menu item.
- Click on the Preview tab. the barcodes
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.

Once you finish the report design, you can distribute
your report application with Crystal run time files,
barcode fonts and the UFL library.
License
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. You may review the
license
agreement here.
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 Morovia directory.
- Morovia 2D Barcode Fontware Crystal UFL.
This file contains all the 2D barcode font
encoder for Crystal Reports. This file is
called 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 DataMatrix Encoder (ActiveX).
This dll is normally located at c:\program
files\morovia\DataMatrixFontware. 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.
|