add Barcode to a canvas

3 posts, 0 answers
  1. Bart
    Bart avatar
    20 posts
    Member since:
    May 2014

    Posted 11 Nov 2016 Link to this post

    Hi Guys,


    I am creating a dynamic canvas to send to the printer and on this canvas I try add an EAN-13 barcode but I can't get it done.

    Then I saw, telerik ui for wpf has "RadBarcodeEAN13" but this doesn't show anything.

    RadBarcodeEAN13 BarCode = new RadBarcodeEAN13();
    BarCode.Text = "871038168385";
    Canvas.SetLeft(BarCode, template.x * positionfactor);
     Canvas.SetTop(BarCode, template.y * positionfactor);
    when I do something like this
    TextBlock BarCode = new TextBlock();

    the specified textBlock is added ad as text to the canvas (cnvPrint) and ends up in my printer.


    where do I go wrong? unfortunately I'm unable to find any examples for this.

    Thank you for your help

  2. Lance | Manager - Technical Support
    Lance | Manager - Technical Support avatar
    1111 posts

    Posted 15 Nov 2016 Link to this post

    Hi Bart,

    Can you try adding a height to the barcode? and also to make sure the position is correct, try placing it at the top left of the canvas for a quick test.

    I was able to get the Barcode to render in the canvas with the code below and here's a screenshot of the result at runtime.

    public MainWindow()
                RadBarcodeEAN13 BarCode = new RadBarcodeEAN13();
                BarCode.Text = "871038168385";
                BarCode.Height = 100;
                Canvas.SetLeft(BarCode, 0);
                Canvas.SetTop(BarCode, 0);

    Let us know if this doesn't resolve the problem.

    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. Bart
    Bart avatar
    20 posts
    Member since:
    May 2014

    Posted 16 Nov 2016 Link to this post

    Hi Lance,

    Thank you for the answer,

    I did some more tests after your post, and found the following, I added the reference to "Telerik.Windows.Controls.DataVisualization"
    for some reason this didn't work.

    so I removed the reference and added it againg using the telerik menu in visualstudio.

    "telerik / UI for WPF /configure project"

    now the reference is added again and it prints EAN barcodes.

    I'm not sure what the difference is between those 2 methods but it works.

Back to Top