I need asp.net print page task
Project Description:
I have a little task on asp.net, I need to print a text data to receipt printer from web page, I used the subsequent code and it works fine on my local machine:
Service service = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
ServiceFunc serv = new ServiceFunc();
service = serv.GetService(Convert.ToInt32(Session["servid"]));
printpage();
}
catch (Exception ex)
{ }
}
public void printpage()
{
PrintDialog pd = new PrintDialog();
PrintDocument pdoc = null;
pdoc = new PrintDocument();
Response.Write("1");
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 12);
PaperSize psize = new PaperSize("Custom", 300, 400);
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
pdoc.DefaultPageSettings.PaperSize.Height = 600;
pdoc.DefaultPageSettings.PaperSize.Width = 300;
Response.Write("2");
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
Response.Write("3");
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
Response.Write("4");
pdoc.Print();
Response.Write("5");
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font font = new Font("Courier New", 10);
graphics.DrawString("XXX", new Font("Courier New", 9), new SolidBrush(Color.Black), startX, startY + Offset);
}
if you have a solution or another way to print.
Skills required are .NET, ASP, Print, C# Programming