DotNetBrowser更新至v2.4版本,打印API进行了改进和重新设计,支持.NET 5,以及更多改进和修复,欢迎下载体验。
DotNetBrowser迎来v2.4版本更新,为了方便大家尽可能顺利过度新版本,我们特意准备了本指南将帮助您了解新版本都要哪些新增与改动。
新功能
-
打印API进行了改进和重新设计。现在,可以从代码中以静默方式打印页面和文档以及将 页保存为PDF。使用新的打印API,可以:
- 选择打印机设备;
- 提供所需的打印设置,例如纸张尺寸,方向,页面范围等;
- 打印完成时获得通知;
- 取消打印;
- 将当前加载的 页保存为PDF文档等。
下面的示例演示如何将当前加载的 页另存为PDF:
// Tell the Chromium engine to perform the printing programmatically.browser.RequestPrintHandler = new Handler<RequestPrintParameters, RequestPrintResponse>(p => { return RequestPrintResponse.Print(); });// This handler is used for printing regular web pages programmatically.browser.PrintHtmlContentHandler = new Handler<PrintHtmlContentParameters, PrintHtmlContentResponse>(p => { string pdfFilePath = Path.GetFullPath("result.pdf"); // Get the print job for the built-in PDF printer. IPrintJob<PdfPrinter.IHtmlSettings> printJob = p.Printers.Pdf.PrintJob; // Subscribe to its PrintCompleted event and show a message box when it's done. printJob.PrintCompleted += (sender, args) => { BeginInvoke((Action) (() => { MessageBox.Show("Printing completed: n"+pdfFilePath); })); }; // Apply the necessary print settings printJob.Settings.Apply(s => { // Enable printing header and footer. s.PrintingHeaderFooterEnabled = true; // Specify the path to save the result. s.PdfFilePath = pdfFilePath; }); // Tell Chromium to use the built-in PDF printer for printing. return PrintHtmlContentResponse.Print(p.Printers.Pdf); });// Load the web page and wait until it is loaded completely.browser.Navigation.LoadUrl("teamdev.com").Wait();// Initiate printing.browser.MainFrame.Print();
- .NET 5支持。DotNetBrowser经过测试并证明可与.NET 5桌面应用程序集成。
改进
- “打印预览”对话框已从表单顶部剪切下来,并放置在较低位置,以改善用户体验。
- AuthenticateParameters.Realm 属性被添加以提供身份验证挑战的领域。
问题修复
- 在硬件加速模式下,原生进程使用多个标签页与WPF BrowserView实例的CPU和GPU使用率过高。
- 在硬件加速模式下,WPF BrowserView崩溃。
- 通过JS-.NET桥注册/取消注册.NET对象时出现少数内存泄漏。
- Tab键在WPF BrowserView中不能正常使用。
- 在离屏渲染模式下,如果鼠标指针悬停在WPF BrowserView组件外,页面滚动停止。
- 显示弹窗时焦点遍历进入无限循环。
如果你对我们的产品感兴趣,想咨询正版授权折扣价格,请联系客服咨询~
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!