Code 128 Barcode in SSRS (Open Source)
- Thanks to Chris Wuestefeld first of all. Check the Link below: http://www.codeproject.com/Articles/14409/GenCode-A-Code-Barcode-Generator
- Download the Source Code and demo files in code project.
- After downloading, extract the source code which is downloaded http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc3.png
- Right click on the Sample Project, Open the Folder and check the GenCode128.dll will be used in SSRS Reports. http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc4.png
- Copy the GenCode128.dll in SQL Server to register in the SQL Server.
- First of all GenCode128.dll which done localization, into the location: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies ". Reference: http://stackoverflow.com/questions/13379804/could-not-load-file-or-assembly-in-reporting-services http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc5.png
- After Registering the GenCode128.dll successfully in SQL Server.
- Open the Command Prompt with administrator privileges, Type "iisreset" to reset the IIS in SQL Server Machine.
- Now it's time to implement in the Barcode Reporting, Open the SQL Data Tools(Visual Studio 2010 Shell) and Create new Project http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc6.png
- After create new Project, Right click add new item http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc7.png
- Select the Report http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc8.png
- After adding the report, it's time to implement the barcode in reporting. Right click and select the "Report Properties". http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc9.png
- Select the References and add the assemblies, which is registered in "C:\Program Files (x86)\M`icrosoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies" and select the GenCode128.dll and System.Drawing which is .Net Framework 2.0. http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc10.pnghttp://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc11.png
- After adding the Reference, its time to add the code which will generate the Barcode in SSRS. Note : Code which is running is VB.NET for SSRS. Paste this Code: Function PaintBox(ByVal level As String) As System.Drawing.Bitmap Dim objBitmap As System.Drawing.Bitmap objBitmap = GenCode128.Code128Rendering.MakeBarcodeImage(level, 1, True) Return objBitmap End Function
Function PaintBoxBmp(ByVal level As String) As Byte() Dim bmpImage As System.Drawing.Bitmap bmpImage = PaintBox(level) Dim stream As System.IO.MemoryStream = New IO.MemoryStream Dim bitmapBytes As Byte() bmpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp) bitmapBytes = stream.ToArray stream.Close() bmpImage.Dispose() Return bitmapBytes
End Function
http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc12.png
After Adding the Code and Reference. In the Report, Insert Image. http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc14.png
After Selecting the Image, Follow the Screenshot to add the Code http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc15.png
Select the Use this field, Press the Fx Button and Type the following =Code.PaintBoxBmp("Any string") and Press Ok. http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc16.png
Save the Report (CTRL +S) and Preview. http://crmandsilverlight.files.wordpress.com/2015/01/010915_1929_code128barc17.png
Finally the Barcode will generate. Following example I have create without connecting to any database.
Already I have use this code to Connecting with SQL Server and Dynamics CRM. For Example Replace like =Code.PaintBoxBmp(Fields!name.Value)
Finally now no need to search for third party vendor for Barcode generation and its completely open source and once again thanks to the Chris Wuestefeld for Barcode.
Cheers! Happy Coding.