XPS Document Writer 中的 WPF 打印
我已经实现了打印功能,通过使用 PrintVisual 方法在我的 WPF 应用程序中打印一些财务图表。由于用户可以自由更改他/她的窗口大小和/或屏幕分辨率,因此我使用了 LayoutTransform、Measure 和 Arrange 方法来确保打印的图表均匀分布在整个页面上,无论应用程序窗口的大小如何。当用户在实际打印机上打印或选择 PDF 打印驱动程序进行打印时,一切都工作得非常好。布局变换在后台生效并显示在打印中,但用户在屏幕上不会遇到任何闪烁或显示变化。
当用户选择 XPS Document Writer 时就会出现问题。当用户这样做时,屏幕上的布局也会改变。当“另存为”对话框出现时,屏幕布局会根据提供的 LayoutTransform 进行更改,这会使图表变小或变大。当用户保存 XPS 文件或在“另存为”对话框中单击“取消”时,布局将恢复正常。但奇怪的是,只有当我们选择 XPS Document Writer 时才会发生这种情况。
但是,用户不想看到这一点。对于 XPS Document Writer,我该怎么做才能防止这种情况发生?
请建议。谢谢
I've implemented a printing feature to print some of the Financial charts in my WPF application by using PrintVisual method. Since the user is free to change his/her window size and/or screen resolution I've use a LayoutTransform, Measure and Arrange methods to make sure that the printed charts gets spread across the entire page evenly irrespective of the size of the application window. All works absolutely well when the user prints on an actual printer or selects PDF Print Driver to print. Layout transform takes effect behind the scene and that shows up in the print, but the user doesn't experience any flicker or change in display on his screen.
The problem comes when the user selects XPS Document Writer. When user does that, the layout on the screen also changes. When the "Save As" dialog box comes up the screen layout changes based on the LayoutTransform provided, which makes the charts go smaller or bigger. The moment user saves the XPS file OR hit cancel on the Save as dialog box the layout goes back to normal. But the strange part is, this happens only when we select XPS Document Writer.
But, user doesn't want to see this.. What can I do to prevent this to happen in the case of XPS Document Writer?
Please suggest. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以在应用变换之前克隆画布或视觉对象。克隆不是内置于 wpf UIElements 中的,但您可以使用 XamlWriter.Save() 和 XamlReader.Load 通过 XmlReader 进行克隆。谷歌“wpf克隆UIElement”或者我可以发布一些代码,如果你觉得这是可行的方法。
perhaps you can make a clone of your canvas or visual prior to applying your transform. clone is not built-in to wpf UIElements but you can use XamlWriter.Save() and XamlReader.Load to clone via XmlReader. google "wpf clone UIElement" or I can post some code if you feel that's the way to go.