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

Text resolution when printing barcode

2 Answers 127 Views
Barcode
This is a migrated thread and some comments may be shown as answers.
Vicent
Top achievements
Rank 1
Vicent asked on 27 May 2019, 08:32 AM

Hi everybody, I'm evaluating RadBarcode for printing barcodes in thermal printers. My printers have a resolution of 203 dpi in both horizontal and vertical directions. I'm trying to generate an image of the barcode (EAN13) and sending to printer:

 

        public DrawBarcode(Point Location, Size Size, string valor): base(Location)
        {
            this.Valor = valor;
            bc = new RadBarcode();
            bc.Value = valor;
            
            var EAN13 = new Telerik.WinControls.UI.Barcode.Symbology.EAN13();
            EAN13.ShowText = true;

            bc.Symbology = EAN13;
            EAN13.Stretch = true;

            int n = 50;
            while (true)
            {
                try
                {
                    img = bc.ExportToImage(2*n, n);
                    this.size = img.Size;
                    return;
                }
                catch (Exception) { n += 10; }
            }
        }

 

        public override void Draw(Graphics g)
        {
            base.Draw(g);
            g.DrawImage(img, 0, 0);
        }

I have a base class for controling Drag, zoom and rotation but it is not important in this scenario. When I send the image to screen, text is rendered perfectly but when I send the image to the printer, text is not redeable. Is it any why to specify resolution in ExortToImage or any other why to change generated image resolution?

 

 

2 Answers, 1 is accepted

Sort by
0
Vicent
Top achievements
Rank 1
answered on 27 May 2019, 03:00 PM
Maybe my question is a bit confusing. I would like to know if it is possible to change resolution of image generated by ExportToImage function.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 May 2019, 06:16 AM
Hello, Vicent,    

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

After some research I have found the following threads which seems to be quite useful about printing an image with high quality and specifying its resolution:
https://docs.microsoft.com/en-us/dotnet/api/system.drawing.bitmap.setresolution?view=netframework-4.8
https://www.codeproject.com/Questions/461866/Change-Image-Resolution
https://social.msdn.microsoft.com/Forums/en-US/66469764-4e0d-4599-9c86-150d51164c70/print-a-form-at-600dpi-rather-than-screen-resolution?forum=winforms

Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. Thank you for your understanding.

I hope this information helps.

Regards,
Dess | Tech Support Engineer, Sr.
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.
Tags
Barcode
Asked by
Vicent
Top achievements
Rank 1
Answers by
Vicent
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or