【问题标题】:.NET Print Any File To XPS With File Name.NET 使用文件名将任何文件打印到 XPS
【发布时间】:2013-05-03 15:54:47
【问题描述】:


我正在尝试在我的 Windows 窗体应用程序中创建使用默认应用程序将任何文件打印到 XPS 的方法。这工作正常,但我无法将目标 XPS 路径传递给打印机,并且总是弹出打开文件对话框。 任何不使用 FindWindow interrop 的建议都会有所帮助。
谢谢!

private void PrintXps(string printFilePath, string destinationXps){
        var printJob = new Process();
        printJob.StartInfo.FileName = filePath;
        printJob.StartInfo.UseShellExecute = true;
        printJob.StartInfo.Verb = "printto";
        printJob.StartInfo.CreateNoWindow = true;
        printJob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        var xps = PrinterSettings.InstalledPrinters.Cast<string>().First(p => p.ToLower().Contains("xps"));
        printJob.StartInfo.Arguments = string.Format("\"{0}\"", xps); 
        printJob.StartInfo.WorkingDirectory = Path.GetDirectoryName(filePath);
        try
        {
            printJob.Start();
            printJob.WaitForExit(); 
        }
        catch (Win32Exception ex)
        {
            MessageBox.Show("File is not supported. "); 
        }
    }

【问题讨论】:

    标签: .net forms printing dialog xps


    【解决方案1】:

    我找到了可行的商业解决方案。它安装自己的驱动程序并提供 .NET api 用于设置文件名。它直接转换为 PDF,但随后可以导出为 XPS。链接在这里:Amyuni PDF Converter

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-01
      • 1970-01-01
      • 2010-09-18
      • 2017-12-31
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 2017-11-10
      相关资源
      最近更新 更多