Not able to use PrintDocument in IIS

六月ゝ 毕业季﹏ 提交于 2020-01-06 05:16:05

问题


I am running an asp.net application's app pool under my ID which has access to Printer. Below is my code which uses DrawString to print a string generated from code.

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

and pd_PrintPage is defined below

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();
        }

    }

Above code works well in my Visual Studio whereas giving error when deployed on IIS. I believe my printer settings and permissions are good as i can print other documents using 'COM' library functions like Word, Excel etc

What's wrong in my shared code? Please suggest

来源:https://stackoverflow.com/questions/52412890/not-able-to-use-printdocument-in-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!