将 GDI 转换为 XPS 时禁止显示 Microsoft XPS Document Writer 上的“另存为”对话框

发布于 2024-07-18 04:11:21 字数 580 浏览 4 评论 0原文

在他的博客文章 无需用户交互即可将文档打印到 Microsoft XPS Document Writer Feng Yuan 说

如果您从自己的应用程序进行打印,则可以轻松指定 MXDW 作为打印机驱动程序并提供要保存到的 XPS 文档的文件名

任何人都可以解释如何执行此操作并提供代码示例吗?

我遇到的主要问题是禁止 Microsoft XPS Document Writer 弹出的“另存为”对话框。 我讨厌像袁在他的帖子中那样诉诸用户界面黑客。

目前,我的应用程序在用户想要使用的打印机的设备上下文上进行 GDI 绘图调用。 我可以在 XPS Document Writer 上进行这些调用,但是当需要完成打印时,XPS Writer 会弹出“另存为”对话框。

In his blog entry Printing documents to Microsoft XPS Document Writer without user interaction Feng Yuan says

If you're printing from your own applications, it's easy to specify MXDW as the printer driver and provide a file name for the XPS document to be saved to

Can anyone explain how to do that and provide a code sample?

The main problem I am having is suppressing the Save As dialog that the Microsoft XPS Document Writer pops up. I am loathed to resort to UI hacking as Yuan does in his post.

Currently my application makes GDI drawing calls on the Device Context of what ever printer the user wants to use. I can make those calls on the XPS Document Writer fine, but when it come times to complete the printing the XPS Writer pops up the save as dialog box.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜点 2024-07-25 04:11:21

事实上,同一作者提供了答案 打印到 Microsoft XPS Document Writer,无需显示文件保存对话框。 解决方案是使用 Microsoft XPS Document Writer 打印机打印到文件。

Indeed the same author provides the answer Printing to Microsoft XPS Document Writer without showing File Save Dialog Box. The solution is to print to a file using the Microsoft XPS Document Writer printer.

亚希 2024-07-25 04:11:21

如果您想避免 XPS 文档损坏文件系统,Shahed Kahn 在 从 MemoryStream 加载 XPs

And if you're wanting to avoid hitting the filesystem with your XPS document, Shahed Kahn gives sample code in Loading Xps From MemoryStream.

七颜 2024-07-25 04:11:21

这对我有用:

  With Me.PrintDocument
     With .PrinterSettings
        .PrinterName = "Microsoft XPS Document Writer"
        .PrintToFile = True
        .PrintFileName = "c:\test.xps"
     End With
    .Print()
  End With

据我所知,这是没有记录的。 尝试一下,您将不会看到可怕的“另存为”对话框。 相反,您会得到一个由 MXDW 生成的干净的 XPS 文件 (c:\test.xps)。

Here's what works for me:

  With Me.PrintDocument
     With .PrinterSettings
        .PrinterName = "Microsoft XPS Document Writer"
        .PrintToFile = True
        .PrintFileName = "c:\test.xps"
     End With
    .Print()
  End With

As far as I know, this is undocumented. Give it a try and you won't get the dreaded Save As dialog. Instead you get a clean XPS file generated by MXDW (c:\test.xps).

━╋う一瞬間旳綻放 2024-07-25 04:11:21

只需删除并重新安装 Microsoft XPS Document Writer,重新安装时请按照以下步骤操作。

转到“开始”-“控制面板”-“添加新打印机”。 然后选择本地打印机和创建新端口。 在组合框中选择本地端口。 将出现询问端口名称的对话框。 为了让我们的 XPS 驱动程序打印到指定文件而不询问用户位置,请写入此输出文件的完整路径。 该文件目前不需要存在(例如 c:\mydriveroutput.xps)。

有关详细信息,请参阅此链接:https://kibitzercz。 blogspot.in/2012/01/building-and-using-xpsdrvsmpl-under.html

Just remove and re-install Microsoft XPS Document Writer, follow the steps below during re-installation..

Go to Start - Control Panel - Add new printer. Then choose Local printer and Create new port. Select Local Port in combo box. The dialog asking for a port name will appear. For our XPS driver to print to specified file without asking a user for a location, write in full path for this output file. This file need not to exist at the moment (something like c:\mydriveroutput.xps for example).

See this link for detail: https://kibitzercz.blogspot.in/2012/01/building-and-using-xpsdrvsmpl-under.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文