[UWP]是否没有用于打印格式化内容的UWP WebView API? [英] [UWP] Is there no UWP WebView API for printing formatted content?
问题描述
Microsoft希望我们为Microsoft Store构建应用程序,并提供了许多优秀的工具。话虽如此,为什么这样一个明显的用例仍然被忽略?其他主要的应用程序平台都有一个API可用,而Edge浏览器确实有一个打印函数
甚至可以关注CSS媒体查询的格式和分页。我认为原因与任何平台限制无关。也许有一个与安全相关的原因?有没有人有这方面的任何信息?
所以你想打印webview吗?是的,用于打印的webview没有直接的API。但是你可以创建一个 WebViewBrush 并绘制webview
在一个矩形中。然后你可以打印矩形。
像这样:
WebViewBrush brush = new WebViewBrush();
brush .SetSource(myWebView);
brush .Redraw();
myRect.Fill = Brush;
< WebView Name =" myWebView"源= QUOT; HTTP://www.bing.com"宽度= QUOT; 1024"高度= QUOT; 500" />
< Rectangle Name =" myRect"宽度= QUOT; 1024"高度="500"/>
要在UWP中打印,您可以参考此文档:从您的应用打印。还有一个官方样本:打印
样本。
祝你好运,
Roy
Microsoft wants us to build apps for the Microsoft Store, and provides lot of great tools to do so. That being said, why is such an obvious use case still ignored? Other major app platforms have an API available, and Edge browser does have a print function that even pays attention to CSS media queries for formatting and pagination. I would assume that the reasons are not related to any platform limitation. Perhaps there is a reason related to security? Does anyone have any information about this?
Hi,
So you want to print the webview right? Yep, there is no directly API from webview used to print. But you could create a WebViewBrush and draw the webview in a rectangle. Then you could print the rectangle.
Like this:
WebViewBrush brush = new WebViewBrush(); brush .SetSource(myWebView); brush .Redraw(); myRect.Fill = Brush;
<WebView Name="myWebView" Source="http://www.bing.com" Width="1024" Height="500"/> <Rectangle Name="myRect" Width="1024" Height="500"/>
And for printing in UWP, you could refer this document:Print from your app. There is also an official sample for this:Printing Sample.
Best regards,
Roy
这篇关于[UWP]是否没有用于打印格式化内容的UWP WebView API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!