代码之家  ›  专栏  ›  技术社区  ›  Lara

无法在IIS中使用PrintDocument

  •  0
  • Lara  · 技术社区  · 7 年前

    我在办一个asp.net我的ID下的应用程序池可以访问打印机。下面是我使用的代码 DrawString

     PrintDocument pd = new PrintDocument();
     pd.PrinterSettings.PrinterName = @"\\aPrint\0007-BOND";
     pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
     pd.Print();
    

    pd_PrintPage 定义如下

    private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            try
            {
                System.Drawing.Font f = new System.Drawing.Font("Courier New", 12);
                ev.Graphics.DrawString(props, f, Brushes.Black, 100, 100);
                ev.HasMorePages = false;
            }
            catch(Exception ex)
            {
                ex.ToString();
            }
    
        }
    

    Word , Excel

    0 回复  |  直到 7 年前
    推荐文章