如何使用Process C#打印到文件

问题描述

我想使用Tiff图像打印机将PDF打印到图像。我不想在代码中使用第三方,因此我正在使用Process来实现它。但是我不知道如何以静方式打印文件,打印机始终显示对话框以指定目的地。谁能帮我吗?非常感谢。 这是我的代码

public class PrinterTest
{
    private const string adobeReaderPath = "C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroRd32.exe";
    private const string filePath = "D:\\Documents\\test.pdf"; 
    private const string printToFile = "D:\\Documents\\test.tiff"; 
    private const string printerName = "TIFF Image Printer 11.0";

    public void Print()
    {
       var printerName = "TIFF Image Printer 11.0";
        var args = string.Format("/t \"{0}\" \"{1}\" \"{2}\"",filePath,printerName,printToFile);

        var startInfo = new processstartinfo()
        {
            CreateNowindow = true,Verb = "printto",FileName = adobeReaderPath,Arguments = args,ErrorDialog = false,UseShellExecute = false,WindowStyle = ProcessWindowStyle.Hidden
        };

        var process = Process.Start(startInfo);
        if (!process.WaitForExit(20000))
        {
            // Kill Adobe Reader/Acrobat
            process.Kill();
        }

        process.Close();
    }

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)