| |
   
Morovia.com Home | Fonts | Components | Labeling | Library | Order | Forum  
   Search for

   Advanced Search
 

 

Home >> Fontware >> Support >> Report Service: 2D Fontware

Using Morovia 2D Fontware products in Microsoft Reporting Service

To download the file needed for this article, click here (ZIP, 92K).

Microsoft® SQL Server Reporting Service stores report definitions in the report server database. The report definitions are created using Report Definition Language (RDL), an XML format that describes each element in a report, including the data model, format, and expressions.

The most important part of the Reporting Service is the Report Designer, a tool for creating and publishing report definitions. Report Designer works with Microsoft Visual Studio 2003 and 2005, allowing developers to quickly design and deploy a report. For more information, see Microsoft documentation.

In order to use 2D barcode fonts in Reporting Service, you need to download the support assembly from our web site. The assembly wraps several calls in managed code. Currently we release the code in a separate package. However, we expect to add the Reporting Service support into the future releases of PDF417 and DataMatrix Fontware products.

1. How does 2D Fontware work?

To create a two dimensional barcode using true type font, there are two distinct processes: encoding and rendering.

In the encoding process, the data to be encoded are applied with various algorithm, including error correction, and are finally translated into a two dimensional array comprising 1 and 0 only. Further these 1s and 0s are compressed into 16 characters, each character drawing a couple of cells. We call the string generated from the encoding process Barcode String.

After you have the barcode string, all you need is to format the whole string with our font and select an appropriate font size. This is the rendering process.

Figure 1. Barcode creating process

Barcode creating process

2. Installing Support Assembly

The file name for the assembly is Morovia.SupportTools.ReportService.dll. Copy this DLL to two folders below:

  • Report Designer folder [Program Files]Microsoft SQL Server\80\Tools\Report Designer.
  • Deploy folder [Program Files]Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin.

Note: the support assembly calls the Encoder COM object at the background. As a result, you still need to have the Encoder COM DLL available and registered on the computer that runs Reporting Service.

3. Tutorial

In this tutorial, we add a column called barcode, which encodes the table column CustomerID in data matrix format. Although the data encoded may have variable length, we want all data matrix barcodes having the same size - a rectangle symbol of 12 by 26 modules.

Procedure 1. Adding DataMatrix barcodes in Report Designer

  1. If you are adding barcodes into an existing project, skip to step 8. Now we start a new project. From Visual Studio, select File | New | Project. In the Project Types list box, click on Business Intelligence Projects. In the Templates box, select Report Project Wizard. Give the project a name and click OK.
  2. On the next screen, the Report Wizard asks for the data source. For simplicity we use the NorthWind database here, which is installed by default when installing SQL Server. You can type the connection string in the edit box directly, or you can have the wizard fill out for you by clicking the Edit... and select the appropriate choices from the Data Link Properties... dialog followed.

    After you finish constructing the connection string, click Next.

  3. At this step, the Report Wizard asks for a query string which will be used to populate the data set in the report. You can enter something like Select * from Customers; or you can click on Edit to pop up Query Builder to build the query. Make sure that you include CustomerID in the result set.
  4. Next, select the type of the report (tabular or matrix). Click Next.
  5. Now select the fields which will be displayed in the report. In the Available fields list box, use your mouse and CTRL key, select CustomerID, CompanyName and ContactName fields. Click on the Details< to move them to the right.
  6. Follow the instructions to complete the wizard.
  7. On the left side, switch to Solution View. Click on the Reports node to find the report just created. Double click on the report file name to bring it up to the right side. You will notice that three tabs appear on the right view, and the current position is at Layout tab. In the report, a filed name is expressed something like Fields!CustomerID.Value.
  8. We now start to add a new column to hold the barcodes. Click on the Company title once, the report responds by showing a header row on the top. Right click on the header row, and select Insert Column at the right. Give the new column a title “Barcode”.
  9. To define the value for the column, you need to tell that you are going to use the the assembly from Morovia. When the current view is the report, the Report menu is visible on top of Visual Studio. Select Report followed by Report Properties to bring up the Report Properties dialog.
  10. Click on the reference tab. In the top list box, click on the button. Click on Browse button once to locate the assembly: Morovia.SupportTools.ReportService.dll.
  11. Click on the General tab (or you can click >>Basic button to see a simple form. Move the cursor to the Value edit box. Enter the following:
    =Morovia.SupportTools.ReportService.
    FontEncoder2D.DataMatrixEncode2(Fields!CustomerID.Value, 26) 

    The name is a little long. But we are working in the .Net world. Make sure that you entered them correct.

    The last part of the definition is the function name. Here we use DataMatrixEncode2 to make all barcodes the same size. Here 26 is the DataMatrixTargetSizeID (if you do not know the meaning of this parameter, see the DataMatrix Fontware Reference Manual). If uniformed size is not required, you can also use the DataMatrixEncode function.

  12. Click on the Font tab. From the font list, select MRV DataMatrix. Click OK to dismiss the dialog.
  13. Click on the Preview tab to view the report. The report should show as below:
  14. If you see a different shape rather than a rectangle, or just portions of a barcode, the width or the height of the column is too small for the barcode. Go back to the Layout view and use your mouse to make appropriate adjustments.
  15. After you are satified with the report, click Build | Deploy Solution, to deploy the solution to the Report Server.

When there is an encoding error, for example, the data is too large to be encoded in the size specified, the function returns an error message in the place of the barcode. If an irregular barcode appears while there are enough spaces for the barcode display, most likely an error occurred. If that is the case, format the field with a text font and examine the message. If the size specified is too small, set a size that is capable of encoding the whole data, or set it to 0 for automatic size selection.

4. Function List

4.1. DataMatrixEncode

Description

Returns the barcode string for the data to be encoded. The barcode string becomes a data matrix barcode after being formatted with Morovia DataMatrix font. The barcode produced has the smallest possible size.

Syntax

String DataMatrixEncode(String strDataToEncode);
  • strDataToEncode

    A string type holds the data to be encoded.

Remarks

To use the function in Reporting Service, call

Morovia.SupportTools.ReportService.
FontEncoder2D.DataMatrixEncode(fieldname)

4.2. DataMatrixEncode2

Description

Returns the barcode string which becomes a data matrix barcode after being formatted with a Morovia DataMatrix font. This function allows you to specify the size that you desire.

Syntax

String DataMatrixEncode2(String strDataToEncode, int target_size)
  • strDataToEncode

    A string type holds the data to be encoded.

  • target_size

    An integer which indicates the DataMatrix shape. The value must be between 0 and 30. If the value is 0, the function produces the smallest barcode possible. You need to make sure that the size is big enough to hold the data, otherwise an error is returned.

Remarks

The list of valid data matrix sizes can be found in DataMatrix Fontware reference manual. Each size has a different data capacity. For example, value 26 produces a data matrix barcode of 12 X 26 cells.

To use this function in Reporting Service, call

Morovia.SupportTools.ReportService.
FontEncoder2D.DataMatrixEncode(fieldname, target_size)

4.3. PDF417Encode

Description

Returns the barcode string which becomes a PDF417 barcode after being formatted with a Morovia PDF417 font. The barcode is created under SecurityLevel at 9 (automatic), and both MaxRows and MaxCols are 0 (i.e. you have no control over the final size of the barcode).

Syntax

String PDF417Encode(String strDataToEncode);
  • strDataToEncode

    A string type holds the data to be encoded.

Remarks

To use the function in Reporting Service, call

Morovia.SupportTools.ReportService.
FontEncoder2D.PDF417Encode(fieldname)

4.4. PDF417Encode2

Description

Returns the barcode string for the data to be encoded. The barcode string becomes a PDF417 barcode after being formatted with a Morovia PDF417 font. This function allows you to specify the number of rows, the number of columns and the security level. For the meaning of each field, refer to PDF417 Fontware Reference Manual.

Syntax

String PDF417Encode2(String strDataToEncode, 
	int max_rows,
	int max_cols,
	int security_level);
  • strDataToEncode

    A string type holds the data to be encoded.

  • max_rows

    The number of rows in the PDF417 barcodes created. Must be either between 3 and 90, or 0, under which the program determines the actual value used.

  • max_cols

    The number of columns in the PDF417 barcodes created. The valid range for this parameter is between 0 and 30. When 0 is specified, the program determines the actual value used.

  • security_level

    The security level to be used in the PDF417 barcodes created. A PDF417 barcode can have security level ranging from 0 and 8. The program uses 9 for automatic selection of security level.

Remarks

To use the function in Reporting Service, call

Morovia.SupportTools.ReportService.
FontEncoder2D.PDF417Encode2
	(fieldname, max_rows, max_cols, security_level)

5. Other Issues

Since the barcodes created are actually text formatted with barcode fonts, the fonts must be available on the client computer to view and print reports. Also you should note that Microsoft SQL Server Reporting Service does not embed fonts when exporting reports to PDF documents. As a result, in order to view and print exported PDF documents each client computer will also need to have the fonts available.

For more information about PDF rendering, see the related section in MSDN.

 

To top of page