关于服务器端打印

    技术2022-05-11  69

    关于服务器端打印(直接控制打印机打印,不是ie打印,不是打印web页面) using System.Drawing.Printing;   protected void Button1_Click(object sender, EventArgs e)     {         foreach (GridViewRow gr in GridView1.Rows)         {                         if (Convert.ToInt16(gr.Cells[2].Text) != 0)             {                 PrintDocument p = new PrintDocument();                 p.PrinterSettings.PrinterName = @"打印机名字";                 p.PrinterSettings.Copies = Convert.ToInt16(gr.Cells[2].Text);//需要打印的份数                 /*foreach (string s in PrinterSettings.InstalledPrinters)                    Response.Write(s+"<br>");*/                 s = gr.Cells[0].Text;                 p.PrintPage += new PrintPageEventHandler(this.p_PrintPage);//delegate                 p.Print();             }         }     }     public void p_PrintPage(object sender, PrintPageEventArgs ev)     {         Bitmap b = MyImage.Generate();//Generate返回一个bitmap对象         ev.Graphics.DrawImage(b, new Point(30, 50));     } 上述调试时正常,网页发布出去后,调用的打印机必须是发布网页的机器上的本地打印机,如果是网络打印机,实际机器不在发布网页的机器上则上述打印无效,没有反应,不知道为什么??  

    最新回复(0)