This is a migrated thread and some comments may be shown as answers.

Generate BarCode Image programmatically

4 Answers 1054 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bertha
Top achievements
Rank 1
Bertha asked on 24 Sep 2018, 05:41 PM

I want to generate the image of BarCode without showing on the WinForm.  How to assign "Code39Extended" to Symbology?

 RadBarcode rBL = new RadBarcode();
 rBL.Symbology = "Code39Extended";

Thanks.

 

4 Answers, 1 is accepted

Sort by
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Sep 2018, 01:56 PM
Hello, Bertha,  

You can find below a sample code snippet demonstrating how to export a RadBarcode as an image without actually showing it on the form:

private void radButton1_Click(object sender, EventArgs e)
{
    RadBarcode radBarcode1 = new RadBarcode();
    Telerik.WinControls.UI.Barcode.Symbology.Code39Extended code39Extended1 = new Telerik.WinControls.UI.Barcode.Symbology.Code39Extended();
    radBarcode1.Symbology = code39Extended1;
    radBarcode1.Value = "123456";
    radBarcode1.LoadElementTree();
    string fileName = @"..\..\exported.png";
    Image img = radBarcode1.ExportToImage();
    img.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
    Process.Start(fileName);
}

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Stefan
Top achievements
Rank 1
Iron
Iron
Iron
answered on 26 Apr 2021, 01:53 PM

Hello,

how can we specify the barcode size like this? Using the parameters for `ExportToImage` the image size changes, but not the size of the barcode itself (at least not the width)...

 

Kind regards.

0
Nadya | Tech Support Engineer
Telerik team
answered on 27 Apr 2021, 10:31 AM

Hello, Stefan,

The ExportToImage method has several overloads which allow you to specify the size of the exported image. Thus, you can control how big the bar code image will be. 

If I understand your question correctly you would like to specify the size of the RadBarcode itself. To achieve this you can use the Width and Height properties:

RadBarcode radBarcode1 = new RadBarcode(); radBarcode1.Width = 50; radBarcode1.Height = 50;

I hope this helps. Should you have other questions please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Stefan
Top achievements
Rank 1
Iron
Iron
Iron
commented on 30 Apr 2021, 06:52 AM

Hello Nadya,

this doesn't seem to work for us properly. I'll create a new thread for this, so that I can attach files/images...

Kind regards.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Apr 2021, 07:03 AM | edited on 30 Apr 2021, 07:07 AM

Hi, Stefan,

I have attached a sample project for your reference. The following image is obtained on my end:

I will have a look at the other ticket as well and we can discuss the scenario further.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
General Discussions
Asked by
Bertha
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Stefan
Top achievements
Rank 1
Iron
Iron
Iron
Nadya | Tech Support Engineer
Telerik team
Share this question
or