Skip to main content
Submitted by Michael Heydasch on 4 August 2012

Printing Barcodes to an RTC Report

ArcherPoint How-To Blog: Step-by-step instructions on how to perform specific tasks in Microsoft Dynamics NAV

I was recently challenged to print a barcode on an RTC report. In the past, I have found barcode fonts rendered perfectly on NAV Classic reports. Those same barcode fonts would not render on the RTC report I was creating.

After trying several different barcode fonts with no success, I began to research online.   I found several posts discussing an inability to embed fonts. (Whether this is due to Reporting Services or RDLC is unclear to me.)

In my online searches, I also found freeware code submitted to Mibuso by Stijn Bossuyt labeled “EAN 8/13 Code 39/128 Barcode Creator v1.5”. (On the download page, credit is shared with Igor Pchelnikov, who submitted “Interleaved 2 of 5 Barcode Creator”.)

This utility works by encoding the barcode value, generating a barcode image in BMP format, and storing the image in a temporary record using table TempBlob.   While four objects are in the FOB and the TXT export file, only one of them – the codeunit – is required to be in a licensed range and may have to be renumbered.

The barcode is generated by a simple function call:  BarcodeMgt.EncodeCode128('*' + "Warehouse Location" + '*',2,FALSE,tempBlob2);  The first parameter is the text to encode, the second parameter is the size (1-5), the third parameter is whether the barcode should be generated as vertical, and the fourth parameter is a reference to the temporary record where the barcode image should be stored.

Proceeding further in my testing, I added a PictureBox to the Classic layout and changed the following properties:

  • SourceExpr, tempBlob.Blob
  • DataSetFieldName, BarcodePic

In Visual Studio, I dragged an Image control from the Toolbox to the layout and changed the following properties:

  • MIMEType, image/bmp
  • Source, Database
  • Value, =Fields!BarcodePic.Value

To my utter surprise, this worked on the first try. So I downloaded an app entitled “Barcode Scanner” to my Android smartphone and tested the barcode image with the app. Again, to my surprise and satisfaction, the barcode registered successfully within a fraction of a second.

I discovered one caveat … creating the barcode image seems to require a tremendous surge in CPU usage.   I found this out by accident when a couple dozen records or more matched the report filter and the report took a minute or so to render before appearing.   (During that delay, the CPU maxed out.)   So long as only one or a few barcodes are rendered in a single report run, the delay in report rendering is entirely acceptable.

sample barcodeThis alternative to barcode fonts for the purpose of barcode printing in the RTC was a nice piece of freeware.   Thanks and kudos to the creators.

If you enjoyed this blog, you might like to check out our collection of Development Blogs, as well as our "How To" blogs for practical advice on using Microsoft Dynamics NAV.

Blog tags