如何在 Windows 8.1-10 上打印 pdf 文件?打印和打印到动词不再起作用?

Art*_*m G 5 .net c# printing pdf command-line

如何从 Windows 8-10 上的代码打印 pdf 文档?我得到下一个例外:Additional information: The specified executable is not a valid application for this OS platform. 当我制作 proc.Start() 时。这是因为我尝试调用的不是 exe,而是 pdf 文件。

这种方法适用于 Windows 7。在较新的版本上它不起作用。

private void SendToPrinter()
    {
      var proc = new Process
        {
            string fileName = "c:\output.pdf"
            StartInfo = new ProcessStartInfo
            {
                Verb = "printto",
                FileName = fileName,
                Arguments = "\"" + printerName + "\"",
                WindowStyle = ProcessWindowStyle.Hidden,
                CreateNoWindow = true,
                RedirectStandardOutput = true,
                UseShellExecute = false
            }
        };

        proc.Start();
        proc.WaitForInputIdle();

        Thread.Sleep(3000);

        if (!proc.HasExited && !proc.CloseMainWindow())
        {
            proc.Kill();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我尝试从控制台执行此操作,键入如下:

"c:\output.pdf" printto "PDFCreator" 
Run Code Online (Sandbox Code Playgroud)

或者像这样:

"c:\output.pdf" -verb printto "PDFCreator" 
Run Code Online (Sandbox Code Playgroud)

printto动词根本不起作用,只需打开 Foxit Reader,如果我这样键入,print动词会显示“当前已打印”

print "c:\output.pdf" "PDFCreator"
Run Code Online (Sandbox Code Playgroud)

但没有任何结果我不仅尝试打印到文件,而且还尝试使用普通打印机。JPG 从代码打印得很好,但不是 pdf。