【发布时间】:2021-06-06 10:26:56
【问题描述】:
我正在尝试使用 Microsoft Print to PDF 打印机将 XPS 转换为 PDF。
我尝试使用 GhostReader 通过命令行转换我的 XPS 文件,还尝试使用 PdfSharp.Xps。这两个都太慢了,一个 10 页的 XPS 文件需要 30 多秒。现在我的问题是,当我使用 Microsoft 打印到 PDF 时,是否可以设置打印的输入和输出文件/路径
string fileGuid = Guid.NewGuid().ToString();
string xpsFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"{fileGuid}.Print.xps");
string pdfFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"{fileGuid}.Print.pdf");
PrintDocument doc = new PrintDocument()
{
DocumentName = xpsFile,
PrinterSettings = new PrinterSettings()
{
PrinterName = "Microsoft Print to PDF",
PrintToFile = true,
PrintFileName = pdfFile,
}
};
doc.Print();
这是我尝试过的。但这会创建一个我无法使用的空 .PDF 文件
【问题讨论】:
标签: wpf pdf .net-core printing xps