Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks


Welcome to the Mobile Line Of Business Blog

Tag Cloud


Post Categories


A customer of mine for years has been using a very expensive bit of labelling software to produce pallet labels.

I’ve made use of this software invoking it from the command line to print labels from a windows service that polls a database table of print jobs.

This has worked very nicely, in that all the web-services for my mobile application need to-do is drop a description of what label needs to be produced and what printer to send it to into a row in a database table, and my service does the rest.

So this was all working very nicely and happily handling over 200 handhelds connecting to the service and producing labels across 40 printers at the rate of about 1 label every 8 seconds.

However commercial pressures dictated that we took our expensive bit of labelling software out of the mix.    It was time to try and print directly to the printers just using straight .net code.

So how to produce complex pallet labels with barcodes on them without using 3rd party components?      The answer dear friends was to use reporting services and some .Net code to produce the barcodes.    Lets cut to the end result,  here’s the labels I was trying to produce.


I also wanted to put a vertical barcode down the right hand side (but hadn’t got a screenshot prepared of that).

Reporting services makes the batch production of labels really straight forward.

I built a visual studio project containing a RDLC representation of my report.     I bound the report with a custom class to store all of my reporting values.    Following the guide at -

I was able to get my report to print from my windows service.

So far so good.   It took a bit of tweaking to get it to print nicely to fit on an A5 label.  Several 100 prints (and lots of paper, later) I had something that looked pretty decent.

The biggest gotcha was ensuring that you render your reports to EMF and that you carefully look at the scaling when it comes to printing the EMF on the PrintPage callback.

As ever happy to share source on this.

The final component was to add the barcodes.   I needed to encode a couple of fields as Code 128 barcode representations.  I found a Wikipedia article on how to do this,  and wrote my own.  Since doing this I have since found better versions, like

So anyhow,  once I had my barcode as a bitmap,  i was able to save this to a byte array (in PNG format), with a bit of code like

Bitmap image = // get our barcode bitmap

MemoryStream stream = new MemoryStream();
                    image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);

The report was then able to bind and image field on the report to my bitmap.

So the solution is now deployed,  it runs happily in the background listening to requests to print labels.   It seems stable and the printed output looks great.

To deploy the soloution I needed to install the SQL 2008 Reporting Services viewer on my servers – link here


Who would have thought that labels can be produced of this complexity without 3rd party software.  To the mobile user it looks great,  labels just magically get produced.


posted on Thursday, September 23, 2010 6:19 AM