使用ASP.Net直接打印PDF文件

时间:2019-02-01 11:52:06

标签: asp.net

ProcessStartInfo infoPrintPdf = new ProcessStartInfo();
string printerName = "PRINTER NAME";
infoPrintPdf.FileName = @"C:\Program Files\Adobe\Acrobat 
     1.0\Acrobat\Acrobat.exe";
infoPrintPdf.Arguments = string.Format("/t {0} \"{1}\"",
     Server.MapPath("~/PDF/PDF FILENAME"), printerName);

infoPrintPdf.CreateNoWindow = true;
infoPrintPdf.UseShellExecute = false;
infoPrintPdf.WindowStyle = ProcessWindowStyle.Hidden;
infoPrintPdf.Verb = "Print";
Process printPdf = new Process();
printPdf.StartInfo = infoPrintPdf;
printPdf.Start();
System.Threading.Thread.Sleep(10000);

if (!printPdf.CloseMainWindow())
    printPdf.Kill(); printPdf.WaitForExit();

printPdf.Close();

此代码在localhost上可以正常工作,但是在IIS上托管时,它不会打印。任何人都可以在这方面帮助我,并解决这个问题。非常感谢

致谢

0 个答案:

没有答案