即使CreateNoWindow为true,PdfFilePrinter.Print仍会启动Adobe Acrobat阅读器

时间:2011-06-24 07:49:25

标签: c# pdfsharp

不知何故,使用Adobe Acrobat X,PdfFilePrinter无法阻止Adobe静默打印PDF页面。

这是我的代码:

PdfFilePrinter.AdobeReaderPath = PDFExecPath;
var printer = new PdfFilePrinter(this.documentPath, this.printer);
printer.Print();

这是PdfSharp的来源:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = PdfFilePrinter.adobeReaderPath;
string args = String.Format("/t \"{0}\" \"{1}\"", this.pdfFileName, this.printerName);
//Debug.WriteLine(args);
startInfo.Arguments = args;
startInfo.CreateNoWindow = true;
startInfo.ErrorDialog = false;
startInfo.UseShellExecute = false;
if (this.workingDirectory != null && this.workingDirectory.Length != 0)
  startInfo.WorkingDirectory = this.workingDirectory;

1 个答案:

答案 0 :(得分:2)

解决:

PdfFilePrinter.AdobeReaderPath = PDFExecPath;
var printer = new PdfFilePrinter(this.documentPath, this.printer);
printer.Print(1000);

Print(int milliseconds)重载会导致adobe acrobat程序失效。