本文介绍了如何在单个条形码上使用换行符或空格嵌入条形码和字符串值中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单个条形码上使用换行符或空格嵌入条形码和字符串值中的数据?我想根据PDF文件中输入的数据获取打印的条形码。以下是我正在使用的代码:

How to embedd data in barcode and string value with line break or space on a single barcode? I want to get the printed bar code on the basis of data entered in the PDF file. Following is the code I am using:

string barCode = txtCode.Text;
         System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
         using (Bitmap bitMap = new Bitmap(barCode.Length * 40, 80))
         {
             using (Graphics graphics = Graphics.FromImage(bitMap))
             {
                 Font oFont = new Font("IDAutomationHC39M", 16);
                 PointF point = new PointF(2f, 2f);
                 SolidBrush blackBrush = new SolidBrush(Color.Black);
                 SolidBrush whiteBrush = new SolidBrush(Color.White);
                 graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
                 graphics.DrawString("*" + barCode + "*", oFont, blackBrush, point);
             }
             using (MemoryStream ms = new MemoryStream())
             {
                 bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                 byte[] byteImage = ms.ToArray();

                 Convert.ToBase64String(byteImage);
                 imgBarCode.ImageUrl =  + Convert.ToBase64String(byteImage);
             }
             plBarCode.Controls.Add(imgBarCode);

推荐答案

这篇关于如何在单个条形码上使用换行符或空格嵌入条形码和字符串值中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 13:53