c# - 通过 Microsoft XPS Document Writer 将 PDF 转换为 XPS

标签 c# xps

使用 Microsoft XPS Document Writer 打印 pdf 文档:

string filename = "C:\\1.pdf";

Process process = new Process();
process.StartInfo.Verb = "PrintTo";

process.StartInfo.FileName = @"C:\Program Files\Adobe\Reader 9.0\Reader\acrord32.exe";

process.StartInfo.Arguments = 
    "/t \"C:\\1.pdf\" \"Microsoft XPS Document Writer\" \"xps\"  XPSPort:";

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;

process.StartInfo.UseShellExecute = false;

process.Start();
process.StandardOutput.ReadToEnd();

process.WaitForExit();

唯一的问题是保存对话框,它要求将文件名 (*.xps) 保存到哪里。大家指教DOCINFO解决这个问题,但我没有找到任何使用的例子。 我需要通过具有默认输出文件名的 Microsoft XPS Document Writer 以编程方式打印 PDF 文件。这种情况应该如何使用DOCINFO?

你能帮帮我吗?

最佳答案

您不能通过生成 Acrobat Reader 可靠地打印,除非您给它一个桌面 session 并且那里会有一个用户,因为它有时会弹出需要用户注意的对话框。

如果在无人看管的情况下使用,也会违反 Adob​​e 的许可。

但是您可以使用 Ghostscript 进行打印。

Ghostscript 有一个 C# 接口(interface),叫做 Ghostscript.Net我已经在一些非常大的项目中成功使用过。 Ghostscript 和 Ghostcript.Net 都是免费和开源的。

关于c# - 通过 Microsoft XPS Document Writer 将 PDF 转换为 XPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2287158/

相关文章:

c# - PACT .NET 消费者测试 : flexible length array

c# - 以编程方式将用户控件添加到工具箱时出现问题

c# - 为什么我可以使用 lambda 表达式代替回调委托(delegate)?

c# - 对对象进行递归过滤Linq

c# - 在 WPF C# 应用程序中将 XPS 转换为 PDF

c# - XAML - 如何反转 UIElement.RenderTransform?

WPF 图像矢量格式导出(XPS?)

c# - 显示从sql db到asp.net网页的信息

printing - 如何在 Windows 8 中打印 xps 文件

wpf - XPSDocumentWriter - 将特定页面打印到特定托盘