Barcode.dll .NET barcode component help
Licensing
- What license types are there?
- How many licenses do I need?
- Do I need a special license for automated build server?
- Is your product royalty free?
- I'm going to distribute component as a part of my software
- Can I receive free updates for the product I purchased?
- Can I use my component when the support expires?
- Which limitations exist in the trial version of the component?
- My license is not working
General
- You can find support on our technical Q&A forum
- Take me to Barcode.dll documentation
- I'm lost, and I need direct support
- How can I be sure that my scanner reads it?
- What barcode types Barcode.dll supports?
Videos
Programming
- How to use Barcode.dll?
- ASP.NET control
- Windows control
- How to change image resolution?
- How to add custom text?
- How to define custom quiet zones?
- How to add bearer bars?
- Using Barcode.dll in SQL Server 2008 Reporting Services
- Using Barcode.dll in ASP 3.0
- How to use Barcode.dll from unmanaged code?
Common problems
- System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission...
- Using ASP.NET control on public pages in protected folders
- ActiveX component can't create object: 'Limilabs.Barcode.BarcodeFactory' (0x800A01AD)
What license types are there?
Single developer + 1 year support
Valid for one developer (royalty free).
1 year support provides updates and support for 1 year.
Single developer + 2 years support
Valid for one developer (royalty free).
2 years support provides updates and priority support for 2 years..
Company + 1 year support
Company license is valid for all developers in one company (royalty free).
1 year support provides updates and support for 1 year.
Company + 2 years support
Company license is valid for all developers in one company (royalty free).
2 years support provides updates and priority support for 2 years.
- Electronic delivery (licenses are generated automatically, you will receive them as soon as the payment is made).
- All licenses are royalty free.
- After the purchase you will receive the license file, which will unlock the trial version. You can download Barcode.dll here.
- Please review our renewal and upgrade discount policy.
Please visit purchase component page for details on how to buy.
How many licenses do I need?
Component is licensed on per-developer basis.
You have to obtain a valid license for each human, who writes the code which directly uses the component.
Do I need a special license for automated build server?
No, only developers need a license.
Is your product royalty free?
Yes, it is.
I'm going to distribute component as a part of my software
All licenses are royalty free.
The component is licensed per-developer, not per user. Once you have purchased a license for each of your developers, you can redistribute the component DLLs with your application royalty free to any number of end users and to any number of computers.
Can I receive free updates for the product I purchased?
Purchasing any product entitles you to 12 months of free maintenance of that product since the moment of purchase. The maintenance includes all major and minor updates released for that product during the year and the standard technical support.
2 years support provides updates and access to priority support for 24 months.
You can renew your support at a discount price, please review our renewal and upgrade discount policy.
Can I use my component when the support expires?
Yes, you can.
Support option refers to component updates and support only. You can renew your support option at a discount price, please review our renewal and upgrade discount policy.
Which limitations exist in the trial version of the component?
The trial version is fully functional. It has the same features as the registered version.
The evaluation version of the component adds watermark to generated barcodes and displays "Please purchase a license" dialog.
My license is not working
Make sure that the "BarcodeLicense.xml" file is in the run folder of your application (AppDomain.CurrentDomain.BaseDirectory).
Please read the after purchase tutorial for more details.
How can I be sure that my scanner reads it?
- Go to Barcode.dll demo.
- Generate your barcode image
- Print it (File/Print...)
- Scan it with your reader
Note: some scanners need correct checksum to be added to the barcode. Use 'Add Checksum?' checkbox to add checksum to your barcode on the demo page.
All barcodes on the demo page are rendered as png files with 150dpi resolution. You may also choose 'Save As..' option, open saved image in Paint and print it. Paint will use the image resolution (150dpi) so barcode will appear smaller.
What barcode types Barcode.dll supports?
Please visit all standards supported page.
How to use Barcode.dll?
If you want to display barcode in user interface use Windows control or ASP.NET control
First you have to add reference to Barcode.dll in your project (see MSDN How to).
C# code
using Limilabs.Barcode; BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.EAN13); barcode.Number = "123456789012"; barcode.ChecksumAdd = true; // Render barcode: this.pictureBox1.Image = barcode.Render(); // You can also save it to file: barcode.Save("c:\\barcode.gif", ImageType.Gif);
VB.NET code
Imports Limilabs.Barcode Dim barcode As BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.EAN13) barcode.Number = "123456789012" barcode.ChecksumAdd = true ' Render barcode: Me.pictureBox1.Image = barcode.Render() ' You can also save it to file: barcode.Save("c:\\barcode.gif", ImageType.Gif)
ASP.NET control
- Create new ASP.NET project
- Add new web.config file if you don't have one.
-
Register HttpHandler in an ASP.NET web application - add the following code to your web.config file:
Register an HTTP handler for IIS 6.0: Register an HTTP handler for IIS 7.0 and IIS 8.0 running in Integrated Mode: Register an HTTP handler for IIS 7.0 and IIS 8.0 running in Classic mode: Replace FrameworkPath with the correct path to the Aspnet_isapi.dll file.If you are using VS2003 use the following:
- If BarcodeControl is not present in the toolbox:
- use the right mouse button on toolbox,
- click 'Choose items...' or 'Add/Remove Items'
- Find 'BarcodeControl' on '.NET Framework Components' tab or click 'Browse' and point 'Barcode.dll' file
- Drag and drop BarcodeControl from toolbox to your webpage. This will add the reference to Barcode.dll to your project.
Windows control
- Create new WindowsForms project
- If BarcodeControl is not
present in the toolbox:
- use the right mouse button on toolbox,
- click 'Choose items...' or 'Add/Remove Items'
- Find 'BarcodeControl' on '.NET Framework Components' tab or click 'Browse' and point 'Barcode.dll' file
- Drag and drop BarcodeControl from toolbox to your Windows Form. This will add the reference to Barcode.dll to your project.
How to change image resolution?
On Windows or ASP.NET controls just use XDpi and YDpi properties.
When generating barcode without controls use following code:using Limilabs.Barcode; using System.Drawing; static void Main(string[] args) { BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.Code39); barcode.Number = "12345"; barcode.ChecksumAdd = true; // Add checksum barcode.Save("c:\\barcode150dpi.png", ImageType.Png, 150, 150); // -or- Bitmap b = barcode.Render(); b.SetResolution(150, 150); // Set resolution b.Save("c:\\barcode150dpi.png", ImageType.Png); }
How to add custom text?
using Limilabs.Barcode; static void Main(string[] args) { BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.Code39); barcode.Number = "12345"; barcode.CustomText = "any text"; // You can put any text here barcode.Save("c:\\barcode.gif", ImageType.Gif); }
How to define custom quiet zones?
Some scanners may need more free space before and after the barcode. This section explains how to change this quiet zones programmatically.
using Limilabs.Barcode; static void Main(string[] args) { BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.Code128); barcode.Number = "12345"; barcode.LeftQuietZone = 20; barcode.RightQuietZone = 20; barcode.SetMarginsAutomaticaly = false; barcode.Save("c:\\barcode.gif", ImageType.Gif); }
How to add bearer bars?
The lines at the top and the bottom of the barcode are called "bearer bars" and are used to prevent something called a "short scan." The bearer bars insure that only complete scans will return a valid read.
using Limilabs.Barcode; static void Main(string[] args) { BaseBarcode barcode = BarcodeFactory.GetBarcode(Symbology.ITF14); barcode.Number = "1234567890123"; if (barcode is IBearerBars) { ((IBearerBars)barcode).BearerBars = BearerBarsType.Horizontal; ((IBearerBars)barcode).BearerBarsSize = 5; } barcode.Save("c:\\barcode.gif", ImageType.Gif); }
Using Barcode.dll in SQL Server 2008 Reporting Services
In 2008 version of the Reporting Services you need to add additional privileges to the code using Barcode.dll.
For preview mode you need to edit the following file: C:\Program Files\Microsoft
Visual Studio 9.0\Common7\IDE\PrivateAssemblies\ RSPreviewPolicy.config
For a deployed report you need to edit the following file: C:\Program Files\Microsoft
SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\ rssrvpolicy.config
Find the CodeGroup with the Report_Expressions_Default_Permissions name:
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="Execution" Name="Report_Expressions_Default_Permissions" Description="This code group grants default permissions for code in report expressions and Code element. "> <IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="0024...."/> </CodeGroup>
Now change the: PermissionSetName="Execution"
to: PermissionSetName="FullTrust"
If you already own the license put the license file (BarcodelLicense.xml) in appropriate
folders: In preview mode license file is loaded from: C:\Program Files\Microsoft
Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
When deployed license
file is loaded from: C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting
Services\ReportServer\
In case of preview you just need to run the report again. In the output window you shouldn't see any SecurityExceptions (A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll)
In case of deployed report please remember to restart ReportServer ("SQL Server Reporting Services (MSSQLSERVER)") service.
Using Barcode.dll in ASP 3.0
Create Barcode.asp file with the following content:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% Option Explicit %> <% Dim bf Dim b set bf = Server.CreateObject("Limilabs.Barcode.BarcodeFactory") set b = bf.CreateBarcode(4) ' Code39 b.FontStyle = 1 ' Bold b.Number = Request.Querystring("number") b.Rotation = 0 Response.BinaryWrite(b.Render(3)) ' gif %>
Very important... this is the WHOLE code for the page... if you keep the html tags and doc content it will not work. This way, it outputs and converts the binary stream of the Rendered barcode and displays it as a gif.
I can now use it this way: from any other page.Special thanks for the code to Yendi N. Gómez Bouchot.
How to use Barcode.dll from unmanaged code?
You can use Barcode.dll from unmanaged code as a COM object:
C++ code:
#include "stdafx.h" #include <atlimage.h> #import "..\..\Redistributables\Barcode.tlb" named_guids int _tmain(int argc, _TCHAR* argv[]) { // Initialize COM. CoInitialize(NULL); Barcode::IBarcodeFactoryPtr pIBarcodeFactory; HRESULT hr = pIBarcodeFactory.CreateInstance( Barcode::CLSID_BarcodeFactory ); Barcode::IBaseBarcodePtr pIBarcode = pIBarcodeFactory->CreateBarcode(Barcode::Symbology_Code39); // Release BarcodeFactory object. pIBarcodeFactory = NULL; // Set some barcode properites. pIBarcode->FontStyle = Barcode::FontStyleType_Bold; pIBarcode->ForeColor = RGB(100, 100, 200); pIBarcode->Number = "123"; pIBarcode->Rotation = Barcode::RotationType_Degrees90; // Save barcode image to file as PNG. pIBarcode->Save("c:\\barcode.png", Barcode::ImageType_Png); // Obtain handle to another memory bitmap. HBITMAP hBitmap = (HBITMAP)pIBarcode->RenderHbitmap(); // Attach CImage object to this handle. CImage image; image.Attach(hBitmap); // Save Cimage object to file as BMP. image.Save(L"c:\\barcode.bmp", Gdiplus::ImageFormatBMP); image.Destroy(); // Release Barcode object. pIBarcode = NULL; // Uninitialize COM. CoUninitialize(); return 0; }
VB code:
Dim bf Dim b Set bf = CreateObject("Limilabs.Barcode.BarcodeFactory") '=Code39. Check Symbology enum for other values. Set b = bf.CreateBarcode(4) ' Set some barcode properites. '=Bold. Check FontStyleType enum for other values. b.FontStyle = 1 b.Number = "12345" '=Degrees90. Check RotationType enum for other values. b.Rotation = 1 ' Save barcode image to file as PNG. '=Png. Check ImageType enum for other values. b.Save "c:\vb.png", 2
System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission...
Right-click on the Barcode.dll and check for the following security message:
This file came from another computer and might be blocked to help protect this
computer.
If present, click "Unblock", "Apply" and "OK".
Please perform the above procedure on:
c:\program files\Limilabs\barcode\redistributables\Barcode.dll
and on all instances of Barcode.dll you have in your solution folder.
Please remember to restart IIS server afterwards.
Using ASP.NET control on public pages in protected folders
If a barcode control is placed on the publically visible page (allow users="*") which is located in a folder that has (deny users="*") attribute, barcode image won't be displayed.
This is because, barcode control is using an http handler for generating images. It allows generating images on the fly without temporary files. The handler name is Barcode.axd and it needs to be added to the web.config with (allow users="*") attribute.
Please add the following code to the 'web.config' file into 'configuration' section:
<location path="Barcode.axd"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location>
ActiveX component can't create object: 'Limilabs.Barcode.BarcodeFactory' (0x800A01AD)
If you are using 2.0 version try the following:- You need to install version 2.0 of the .NET framework (3.0+ versions are not enough). You can download it here: Framework 2.0
- If you did not install the component using the windows installer setup, download Barcode.dll windows installer and install it (be sure to have 'COM support' option checked).
- You need to install version 1.1 of the .NET framework (2.0+ versions are not enough). You can download it here: Framework 1.1
- If you did not install the component using the windows installer setup, download Barcode.dll windows installer and install it (be sure to have 'COM support' option checked).