[UWP]如何在按下打印按钮之前获取有关打印页面的信息 [英] [UWP] How to get info about print page before pressing print button

查看:101
本文介绍了[UWP]如何在按下打印按钮之前获取有关打印页面的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您好,

Hello,

按下打印按钮并创建打印任务后,我可以获得有关打印页面大小和ImageableRect大小的信息,如下所示:

After pressing print buton and creating print Task, I can get info about printing page size, and ImageableRect size, example below:

                PrintTaskOptions printingOptions =((PrintTaskOptions)e.PrintTaskOptions);

                PrintPageDescription pageDescription = printingOptions.GetPageDescription(0)

                PrintTaskOptions printingOptions = ((PrintTaskOptions)e.PrintTaskOptions);
                PrintPageDescription pageDescription = printingOptions.GetPageDescription(0)

推荐答案


PrintDocument.Paginate
事件,或通过
PrintTaskOptions.GetPageDescription
。两者确实仅在打开打印对话框后才可用。这是因为打印页面(及其ImageableRect)的大小取决于用户选择的打印机,纸张尺寸和方向。

Print page description is returned in the PrintDocument.Paginate event, or through PrintTaskOptions.GetPageDescription. Both are indeed only available after opening the print dialog. This is because the size of the print page (and its ImageableRect) depends on the printer that the user selects, the paper size, and the orientation.

您可以在准备之前准备好XAML打印,但您可能必须在实际纸张尺寸已知时重新渲染。

You can prepare your XAML before printing, but you may have to rerender it when the actual paper size is known.

检查
UWP打印示例
,用于示例。


这篇关于[UWP]如何在按下打印按钮之前获取有关打印页面的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆