问题
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