Data Matrix 2D Barcodes in SQL Server Reporting Services SSRS -As Images
How to (easily) create barcodes in SSRS
- BarCodeWiz Data Matrix Fonts may be used to create barcodes as images in SSRS.
- Follow the steps below to add barcodes to your own report.
Before You Begin
- Ensure BarCodeWizFonts.DataMatrix.dll as well as the font files are installed on the server.
- See BarCodeWiz Fonts in SSRS - Installation
Step 1. Configure Report Properties
- Open Properties Window - right-click in the report background area and click Report Properties...
- In the Report Properties window, select the References section.
- 1) Click Add to add the assembly
- 2) Type: BarCodeWizFonts.DataMatrix
- 3) Click Add to add a class instance
- 4) Type BarCodeWizFonts.DataMatrix.DataMatrixFonts for class name and MyDataMatrix for instance name
Step 2. Insert image
- Insert an image into the report by dragging one of the columns from your DataSet.
- In this example, the image is placed inside a Table.
Step 3. Edit Image Properties.
- 1) Right - click on an image and select Properties
- 2) Select Database as the image source
- 3) Select image/png as the MIME type
- 4) Click on the Fx button to open the Expression window
- Set the value for the expression:
=Code.MyDataMatrix.ToImageBytes( Code.MyDataMatrix.Encode( Fields!item_sku.Value, quietZoneWidth:=5 ), "BCW_DM", 8, 300.0 )
- This creates a PNG image with font name BCW_DM, size 8pt, and resolution of 300DPI.
- Replace item_sku with the name of the field from your dataset.
NOTE: For smaller barcodes, you can set the point size as low as 2pt
The report is ready!
- Preview the generated report.