我想从C#代码打印PDF文件,而无需用户交互。
我尝试了这个公认的答案,但它对我不起作用。
这是我尝试的代码:
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = @"G:\Visual Studio Projects\PrintWithoutGUI\PrintWithoutGUI\Courses.pdf" //put the correct path here
};
p.Start();
我得到这个例外:
System.ComponentModel.Win32Exception:'指定的可执行文件不是此OS平台的有效应用程序。
这是编写代码的正确方法
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = "PDfReader.exe", //put the path to the pdf reading software e.g. Adobe Acrobat
Arguments = "PdfFile.pdf" // put the path of the pdf file you want to print
};
p.Start();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句