Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi i want to generate EAN 13 barcode into web application for that i am using zen.barcode.core.dll using this library i am able to generate barcode but issue was i want to print barcode character into same format as EAN 13 like country code,product code,manufacturer code is there any way to print character into same format?

What I have tried:

BarcodeDraw drawObject = BarcodeDrawFactory.CodeEan13WithChecksum;

                //BarcodeDraw drawObject = BarcodeDrawFactory.CodeQr;

                BarcodeMetrics metrics = drawObject.GetDefaultMetrics(60);
                metrics.Scale = 2;
                //text = appendChecksum(text);
                var barcodeImage = drawObject.Draw("123456789012", metrics);
                var resultImage = new Bitmap(barcodeImage.Width, barcodeImage.Height + 20);

                using (var graphics = Graphics.FromImage(resultImage))
                using (var font = new Font("Consolas", 12)) // Any font you want
                using (var brush = new SolidBrush(Color.Black))
                using (var format = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Far }) // To align text above the specified point
                {
                    graphics.Clear(Color.White);
                    // Print a string at the left bottom corner of image
                    graphics.DrawImage(barcodeImage, 0, 0);
                    graphics.DrawString(text, font, brush, resultImage.Width / 2, resultImage.Height, format);
                }

                using (MemoryStream ms = new MemoryStream())
                {
                    resultImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    byte[] imageBytes = ms.ToArray();
                    return Convert.ToBase64String(imageBytes);
                }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900