3

以下是我之前的问题,它工作正常并生成条形码。 我以前的问题

现在,我只想将字符(形成条形码)写在这个条形码(图像)下。我怎样才能做到这一点。?我Barcode Rendering Framework用于生成条形码。请帮忙。

我可以通过获取面板并添加图像和文本(条形码字符)并打印面板来做到这一点吗??

4

1 回答 1

0

我通过使用我添加了创建的条形码图像的 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();
    }
于 2013-08-23T12:24:52.483 回答