Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Print html without page info on brother lable printer

$
0
0

Hey

I am making a system where I need to print a adress lable. I am generating a html code from codebehind ("<h4>" + userName + "</h4><p>" + adress + "<br/>" + zipCity + "</p>"), I have tryede it with this:

private void PrintWebControl(Control ControlToPrint)
{
     StringWriter stringWrite = new StringWriter();
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     if (ControlToPrint is WebControl)
     {
          Unit w = new Unit(100, UnitType.Percentage);
          ((WebControl)ControlToPrint).Width = w;
     }
     Page pg = new Page();
     pg.EnableEventValidation = false;
     HtmlForm frm = new HtmlForm();
     pg.Controls.Add(frm);
     frm.Attributes.Add("runat", "server");
     frm.Controls.Add(ControlToPrint);
     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();
}

but it will not print on the lable printer, and if I print it on normal printer it prints the title and pange numbers on top and site name and date on the bottom.

I will like only to have the html code printet out on the lable printer.


Viewing all articles
Browse latest Browse all 23244

Trending Articles