下面是我之前的问题,它工作正常并生成条形码。My previous Question
现在,我只需要将字符(构成条形码)写在这个条形码(图像)下。我怎样才能做到这一点呢?我使用Barcode Rendering Framework生成条形码。请帮帮忙。
我可以通过使用面板并添加图像和文本(条形码字符)并打印面板来完成吗?
发布于 2013-08-23 20:24:52
我使用asp面板添加了创建的条形码图像。我在下面添加了字符串,即我的条形码字符。然后使用打印助手函数,我就可以打印它们了。下面是我在面板中添加图片和文本的代码。
Code39BarcodeDraw barcode39 = BarcodeDrawFactory.Code39WithoutChecksum;
// Panel pnl = new Panel();
Label str = new Label();
str.Text="SER1012308131";
// System.Drawing.Image img = barcode39.Draw("SER1012308131", 40);
//string path = Server.MapPath("~/Uploads/") + img+".jpeg";
string path = @"~/Uploads/abcd.jpeg";
// img.Save(path);
Image imgg = new Image();
imgg.ImageUrl=path;
pnlpnl.Width = Unit.Pixel(300);
pnlpnl.Height = Unit.Pixel(45);
pnlpnl.Controls.Add(imgg);
pnlpnl.Controls.Add(str);
Session["ctrl"] = pnlpnl;
ClientScript.RegisterStartupScript
(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=45px,width=300px,scrollbars=1');</script>");打印辅助函数。
public PrintHelper()
{
}
public static void PrintWebControl(Control ctrl)
{
PrintWebControl(ctrl, string.Empty);
}
public static void PrintWebControl(Control ctrl, string Script)
{
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
}
Page pg = new Page();
pg.EnableEventValidation = false;
if (Script != string.Empty)
{
pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
}
HtmlForm frm = new HtmlForm();
pg.Controls.Add(frm);
frm.Attributes.Add("runat", "server");
frm.Controls.Add(ctrl);
pg.DesignerInitialize();
pg.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.Write("<script>window.print();</script>");
HttpContext.Current.Response.End();
}https://stackoverflow.com/questions/18401132
复制相似问题