我正在尝试在 asp.net 中显示条形码列表,我已经到处搜索了,我发现 IDAutomationHC39M 是免费的。当我使用带有一个字符串的代码时,我得到条形码底部显示的数字,现在我尝试将它与字符串数组一起使用,我得到的是裸代码列表,但 SYSTEM.S 显示在底部,所以它不读取字符串数组,任何帮助我都会很高兴,这里是我的代码
public String[] Action = { "12345", "76543", "34567", "87654", "34567" };
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnGenerate_Click(object sender, EventArgs e)
{
string barCode = txtCode.Text;
for (int i=1;i<=Action.Count();i++)
{
System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
using (Bitmap bitMap = new Bitmap(Action.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("*" + Action + "*", 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 = "data:image/png;base64," + Convert.ToBase64String(byteImage);
}
}
plBarCode.Controls.Add(imgBarCode);
}
}
在客户端我有一个占位符
<asp:PlaceHolder ID="plBarCode" runat="server" />
你能告诉我我的代码出了什么问题吗?