public MainWindow() { InitializeComponent(); Closing += (s, e) => ViewModelLocator.Cleanup(); mychrome.Address = "file:///E:/test.html"; mychrome.RegisterJsObject("callbackObj", new CallbackObjectForJs()); Closing += new System.ComponentModel.CancelEventHandler(MainWindows_Closing); } public class CallbackObjectForJs { public void showMessage() { //我想在这调用test_print1()方法,应该怎么写? } } public string test_print1() { //打印 PrintDialog pdlg = new PrintDialog(); if (pdlg.ShowDialog() == true) { FlowDocument doc = PrintPreviewWindow.LoadDocumentAndRender("OrderDocument.xaml", GlobalData.m_orderExample, new OrderDocumentRenderer()); Dispatcher.BeginInvoke(new DoPrintMethod(DoPrint), DispatcherPriority.ApplicationIdle, pdlg, ((IDocumentPaginatorSource)doc).DocumentPaginator); } return "文档已打印"; }
wpf,用的cef浏览器加载html页面,html页面上的JS调用c#的方法打印. 所有方法都测试没问题了,就是不知道怎么在CallbackObjectForJs里去调用打印的方法test_print1()
相关问题
- CefSharp get screenshot of a page
- Cefsharp didn't start on Client Machine?
- How to make JAWS screen reader recognize and read
- How to gather all cookies using CEFSharp?
- CefSharp - Could not load file or assembly 'Ce
相关文章
- Layui 的数据表格怎么用JS来赋值?
- How to implement keyboard handler cefSharp for sho
- How to bypass SSL error CefSharp WinForms
- What is the purpose of the cef.pak file in cefshar
- CEFSharp (Chromium Embedded Framework) in Interop
- How do I hide the CefSharp.WinForms.ChromiumWebBro
- Cefsharp and video tag WebRTC
- WPF and CefSharp: sluggish performance
用的什么框架 aspx 还是其他的
这样就行了。
为了防止你再问,如何在JS中调用showMessage,我就先剧透下, js中这样写就行了。
window.CallbackObjectForJs.showMessage();
还是老老实实写一个专门的服务出来吧