Barcode DLL Sample
In this simple guide, you will learn how to use the Barcode DLL component in RDL reports.
System Requirements
Visual Studio (VS) 2005/2008/2010/2012/2013/2015/2017 or Business Intelligent Development Studio (BIDS) 2005/2008 or SQL Server Data Tools
Reporting Services 2005/2008/2008-R2/2012/2014/2016/2017 ANY Edition (Express, Workgroup, Web, Developer, Standard, Enterprise, Business or Datacenter)
In the following sample you'll create a Report Server Project which features barcode images by using Barcode DLL. This project will contain a simple RDL report displaying a List of products from Microsoft's AdventureWorks database sample http://msftdbprodsamples.codeplex.com/
Note
This guide uses Visual Studio 2008 for reference but you can use the same approach if using a different Visual Studio version
Please follow up these steps:
Please ensure you've correctly configured Barcode DLL component
Open Visual Studio (or BIDS or SSDT) and create a new Report Server Project
With the Report Server project opened, add a new Data Source pointing to the AventureWorks database sample
Add a new Report item, name it to ProductList.rdlc, and enter the following SQL Statement:
SELECT ProductID, Name, ProductModel, CultureID FROM Production.vProductAndDescription WHERE (CultureID = N'en')
- Select a Tabular type report and add the ProductID, Name, and ProductModel fields into the Report's Detail section. The report should look like the following figure:
Now it's time to add a reference to Barcode DLL component and write a VB function for generating the barcode images.
- With the report opened at design-time, select Report > Report properties...
- In the Report Properties dialog box, select References tab.
- Add a reference to Neodynamic.ReportingServices.Barcode.dll which should be located under:
- For VS2017 the folder is located at [VSInstallDir]\Common7\IDE\CommonExtensions\Microsoft\SSRS or [VSInstallDir]\Common7\IDE\CommonExtensions\Microsoft\SSDTRS
- For VS2015/VS2013/VS2012/VS2010/VS2008/VS2005 the folder is located at [VSInstallDir]\Common7\IDE\PrivateAssemblies
Finally, select Code tab. When generating barcodes, you should know about what Barcode Symbology you need to encode. Most common symbologies are Code 39, Code 128, GS1-128, GS1 DataBar, EAN-13, UPC-A, Data Matrix, QR Code, etc. The barcode symbology is set up by using Symbology property of Barcode object. In this sample, you will use Code 128 barcode, a common symbology which can be used for encoding full ASCII strings. When using Barcode DLL component, you need to write a custom VB function for generating barcodes which will be later displayed by an Image item on the report. In this sample you will create a VB function called GetBarcode which accept a parameter called valueToEncode which, in general, is a field of the report's data source. Inside this function you will create an instance of Barcode class called objBarcode setting up some properties for generating the barcode image:
Note
Refer to the full Barcode DLL API Documentation for further barcode image generation features!
Public Function GetBarcode(ByVal valueToEncode As String) As Byte()
Using objBarcode As New Neodynamic.ReportingServices.Barcode
'Set the value to encode
objBarcode.Code = valueToEncode
'Set the Code 128 Barcode Symbology
objBarcode.Symbology = _
Neodynamic.ReportingServices.Symbology.Code128
'Set the Bar's height to 0.5 in
objBarcode.BarHeight = 0.5F
'Enable AutoSize
objBarcode.AutoSize = True
'Generate the barcode image
Return objBarcode.GetBarcodeImagePng()
End Using
End Function
- Now, from the VS toolbox, drag & drop an Image item onto the first column of the table.
- The image item will hold the barcode image generated by the GetBarcode function. Select the image item and hit F4 to display VS Properties Window. Set up the following properties:
- Source ↣ Database
- MIMEType ↣ image/png
- Sizing ↣ AutoSize
- Value ↣ =Code.GetBarcode(Fields!ProductID.Value.ToString)
- That's it! Click on the Preview tab to preview the report with barcodes
Deployment
When you are ready for production, you must ensure that Barcode Professional is correctly configured and deployed to your Report Server! All steps for correctly deploying Barcode Professional DLL are stated in the Barcode DLL Deployment topic.
Need Assistance?
- For tech assistance please contact our Tech Support