Problems scanning Radbarcodes

3 posts, 0 answers
  1. John
    John avatar
    16 posts
    Member since:
    Sep 2011

    Posted 09 Oct 2014 Link to this post

    Having trouble getting RadBarcodes to scan unless made larger than default with LineWidth = 2.  UPC-A and EAN are the troublemakers with LineWidth = 1.  ITF-14 scans ok at LineWidth = 1. 

    As documentation suggests, we tried setting Height and Width to empty strings to let control size things as it needs based on LineWidth setting.  Also tried using code like Height = New Unit(1.02, UnitType.inch) and Width = New Unit(1.469, UnitType.inch) to set to standard UPCA 1.02in x 1.469in size, but the RadBarcode control seems to just ignore the settings.  Any clues as to why LineWidth = 1 won't scan?   I can't find any other RadBarcode control properties that would help.

    When I check the industry standard on UPCA, it says that the size is allowed to be anywhere from 80% to 200% of 1.02in x 1.469in.  But I can't find any way to make the RadBarcode create it in anything but mutliple of LineWidth (i.e. LineWidth=1 is default size, LineWidth=2 is twice as large, ...etc).

    Its not a problem with our scanner, which is able to scan other smaller UPCA and ITF14 barcodes (not generated from RadBarcode) without problem. We are using a pretty standard Motorola LS2208 handheld scanner for testing, which is what our vendors are using.

    Declaring control as
    <telerik:RadBarcode runat="server" ID="cuBarCode" Width="" Height="" ></telerik:RadBarcode>

    Setting up in codebehind as follows since we have to support 4 different barcodes types based on user choice...
    Public Sub SetRadbarcodeProperties(ByVal barcodeCtl As RadBarcode, ByVal bc As FPHBarCode)
        barcodeCtl.OutputType = BarcodeOutputType.EmbeddedPNG
        barcodeCtl.Text = bc.Value
        Select Case bc.Type
            Case "ITF-14"
                barcodeCtl.Type = BarcodeType.Code25Interleaved
                barcodeCtl.RenderChecksum = False
                barcodeCtl.LineWidth = 2
            Case "UPC-A"
                barcodeCtl.Type = BarcodeType.UPCA
                barcodeCtl.RenderChecksum = True
                barcodeCtl.LineWidth = 2
            Case "EAN-13"
                barcodeCtl.Type = BarcodeType.EAN13
                barcodeCtl.RenderChecksum = True
                barcodeCtl.LineWidth = 2
            Case "UPC-E"
                barcodeCtl.Type = BarcodeType.UPCE
                barcodeCtl.RenderChecksum = True
                barcodeCtl.LineWidth = 2
            Case Else
                Throw New InvalidOperationException("Cannot handle barcode type=" + bc.Type)
        End Select
    End Sub
  2. Vasil
    Vasil avatar
    1606 posts

    Posted 13 Oct 2014 Link to this post

    Hello John,

    There are two types of rendering for the RadBarcode: PNG and SVG.

    The PNG is basically raster(bitmap) image. The width of the lines in the output image should be integers. For example you can not have line pixel and a half wide.
    In this type of rendering, you have several options:
    • Set LineWidth to some positive number. In this case the image will be shown in your monitor crisp and clear. In case the LineWidth=1 you can scan Barcode if the scanning device has good enough resolution to distinguish between pixels. (If we are talking about scanning it from the display). The browser zoom, screen resolution and DPI will affect how large is your image. So in different monitors it could look different in absolute (inch, cm) size.
    • Set LineWidth=0, and specify Width and Height in pixels. Now the output bitmap will have width of the lines to 1 pixel, but it will be resized in your browser. In this case you will need to assume what could be the monitor DPI and modify multiply it by your target inch sizes. The browsers can upscale using different algorithms and in some cases the result can look blurry. *

    The SVG is on other hand vector format. In this case the lines does not have exact width in pixels, but they are resolved in the browser depending on the screen resolution and DPI and the width of the whole Barcode. In this case each line get's percentage of the whole image, and it can be even resized in the browser.

    Here are two examples, test them and use the more suitable for you:

    RadBarcode1.OutputType = BarcodeOutputType.EmbeddedPNG;
    RadBarcode1.Text = "12345";
    RadBarcode1.LineWidth = 0;
    RadBarcode1.Width = Unit.Pixel(105);
    RadBarcode1.Height = Unit.Pixel(74);
    RadBarcode2.OutputType = BarcodeOutputType.SVG_VML;
    RadBarcode2.Text = "12345";
    RadBarcode2.Width = new Unit(1.469, UnitType.Inch);
    RadBarcode2.Height = new Unit(1.02, UnitType.Inch);

    * You can change the upscale resizing algorithms used by the IE and Firefox using CSS to avoid anti-aliasing when using PNG or other raster graphics.
        image-rendering: -moz-crisp-edges;
        -ms-interpolation-mode: nearest-neighbor;


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. John
    John avatar
    16 posts
    Member since:
    Sep 2011

    Posted 13 Oct 2014 in reply to Vasil Link to this post

    Thanks a bunch for the info.

    It would be helpful (and would have saved me a lot of time) if the RadBarcode documentation included this information about EmbeddedPng.  As far as i can tell, nowhere is it specified that you must set LineWidth=0 for the Height/Width setting to be used (which you say will then actually use a value of 1 for LineWidth even thought you specify 0). 

    Also thanks for the stylesheet info on keeping edges crisp.  This would also be useful info for the documentation.

    I will be trying these changes today and get back if still having trouble.
Back to Top