Barcode support in Windows Azure platform

Are you targeting or planning your projects on Windows Azure platform? If yes, do you need barcode generation on it? If yes, then keep in mind the following. Based on some customers using our barcode generation products, it seems that Azure DOES NOT FULLY SUPPORT GDI+

Why is that important for you? Because our products Barcode Professional for ASP.NET, Windows Forms & SDK leverages GDI+, which is the “default” graphic engine in .NET, for barcode drawing and image generation.

In that post, Yi-Lun Luo (Microsoft, Moderator) is advicing to use a modern graphic engine like WPF. So if you need barcode generation support in Windows Azure, Neodynamic can offer you Barcode Professional for WPF which DOES NOT use GDI+ but Windows Presentation Framework generating vector-based high quality barcodes.

Advertisements

Barcode Professional for Silverlight on NiceLabel Portal from EURO PLUS

Neodynamic’s Barcode Professional for Silverlight is the world’s first barcode component which generates vector based high quality barcodes in Silverlight platform. We designed and developed it to target Silverlight 4.0 LOB apps because we saw a need for a native barcoding solution in such scenarios.

Last month, EURO PLUS d.o.o., a recognized innovation leader in AIDC solutions, announced the availability of NiceLabel Portal – “a true Web-based label printing solution that supports centralized online label printing”.

NiceLabel Portal allows the user to simply click a Web link and print a label. The simplicity of the process is what drives supplier compliance, and when it’s easier for a vendor to print a new label than to resist changing his routine, the ground work for a highly efficient system is set. For the solution provider on the other side, the labeling costs by unifying systems are dramatically reduced.

How Barcode Professional for Silverlight is related to this solution? Well, NiceLabel Portal web printing solution was built on Silverlight and it is using our Barcode Pro for Silverlight for client-side vector based barcode rendering!

We’re very proud to see that our product is being used in such recognized labeling product.

Printing barcodes in Windows Service projects using C# or VB.NET

Some weeks ago, a customer contacted us about some intermittent issues he had when printing barcodes in a Windows Service using our Barcode Professional SDK for .NET

Barcode Pro SDK for .NET is written using 100% managed code based on the “standard” drawing engine provided by .NET Framework which is basically a wrapper around GDI+, that’s System.Drawing classes.

The printing functionality using the “standard” drawing engine is mainly under System.Drawing.Printing namespace and the key class behind it is PrintDocument which we used in some guides demoing barcode printing using our Barcode Pro SDK for .NET

Although this approach seems to be working fine in Windows Forms applications, it seems that in Windows Service it has some limitation or “not supported” tag as is stated in this page which basically says:

Caution
Classes within the System.Drawing.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

Sadly, there’s no solution to that if try to use our Barcode Pro SDK for .NET (or Barcode Pro for Windows Forms) in Windows Service scenarios. However, one possible alternate approach to bypass this issue is to replace the “drawing” engine. Another drawing engine in .NET Framework is the one based on WPF (Windows Presentation Foundation) which was introduced in .NET 3.0

WPF drawing engine is NOT based on GDI+ but on DirectX and the printing classes is available under System.Printing

It seems that WPF printing can be safely used in Windows Service projects. Taken advantage of this, we wrote a guide for printing barcodes in Windows Service using our Barcode Professional for WPF (which is 100% based on WPF drawing engine and NOT on GDI+) In that guide we tried to reproduce two common scenarios i.e. printing a single page document as well as a multipage document with barcodes.

We hope that guide helps you as a starting point for more complex printing scenarios.

Reporting Services & Excel – Barcode image size is not properly displayed

It seems that “autosize” images rendered in any list control of RS is not properly displayed when exporting the RDL report to Excel *.xls format. AutoSize feature of our Barcode Pro for RS ensures that the generated barcode will not be “cut off”. This is very important when you are using variable length linear barcodes like Code 39, Code 128, GS1-128, etc. because the barcode length will depend on the amount of characters in the value to encode. For other barcodes like UPC-A/E or EAN-13/ISBN that is not a problem at all because these standards encode fixed length values and the final barcode size can be calculated from the beginning.

Now, back to the Excel “image autosize” issue, there is a workaround which can be applied to avoid this. It involves you disable AutoSize feature on our product and just specify a fixed size for it through Width & Height properties. The only thing to be aware is that for variable length barcodes, you must specify the greatest size which will depend on your data source field which will be encoded into the barcodes.

Let’s apply the workaround to the sample we provide in the “Getting Started – First Steps with Barcode Professional for SQL Reporting Services” In this guide there’s a sample report listing barcodes for the products of AdventureWorks sample DB available in SQL Server 2008

For “Using Barcode DLL Component” report sample, there is the following VB function which is in the Code section of the RDL report:


Public Function GetBarcode(ByVal valueToEncode As String) As Byte()
'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 Function

In that function, the AutoSize feature is enabled. If you run the RDL report and export it to Excel you get this:

Image auto-size issue when exporting Reporting Services RDL report to Excel

Notice that the barcodes on the Excel file are being “scaled”. The fact is that the barcode image generated by our product is correct (see the “Original size” info) but is scaled down by Excel without apparent reason (In reality, it seems that Excel is honoring the Height of the “table cell” row and scales the barcode image to fit in).

Let’s change some settings on the GetBarcode function by disabling the AutoSize feature and specifying a fixed image size which will contain the rendered barcode.


Public Function GetBarcode(ByVal valueToEncode As String) As Byte()
'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
'Specify fixed size
objBarcode.AutoSize = False
objBarcode.Width = 1F
objBarcode.Height = 0.75F

'Generate the barcode image
Return objBarcode.GetBarcodeImagePng()
End Function

These new settings will generate an image which size is 1in x 0.75in containing a barcode which bar’s height is 0.5in

NOTE: Please notice that the Width & Height properties are for the final image size NOT the barcode bars! The barcode size is determined by a combination of some properties like BarHeight, BarWidth, BarRatio, Code, etc

Other settings must also be done on the Image control which is invoking the GetBarcode() function. Select the Image control and set the Sizing property to FitProportional AS WELL AS the Width & Height properties to the same values you set up in the GetBarcode()function i.e. Width = 1in and Height = 0.75in
Reporting Services Image control settings
That’s it. Now run the report once again and export it to Excel. The barcode images are now displayed correctly without any scaling!
Image size issue solved when exporting a RDL report to Excel

Encoding Unicode in 2D barcode like PDF417, DataMatrix, QRCode or AztecCode

Try encoding Unicode characters in 2D barcodes like PDF417, DataMatrix, QRCode or AztecCode is a challenge because all those standards were not designed to encode Unicode two-byte characters but single-byte strings only.

In a recent guide (with a sample code in VB and C# – Windows Forms), we tried to provide some tips about how to accomplish that in a “reliable way”. The “reliable” word here is very important because there’re many methods for encoding Unicode in barcodes but few of them are, precisely, reliable. We found a simple one leveraging Base64 algorithm.

NOTE: Although the guide was written by using Barcode Professional SDK for .NET, it can be applied to other editions of our products i.e. ASP.NET, Windows Forms, WPF, Reporting Services, etc.)

Encoding Unicode chars in 2D barcodes PDF417-DataMatrix-QRCode-AztecCode in VB-C#