示例#1
0
 public Task PrintAsync(Xamarin.Forms.WebView webView, string jobName, FailAction failAction)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (string.IsNullOrWhiteSpace(jobName))
         {
             jobName = Forms9Patch.ApplicationInfoService.Name;
         }
         WebViewPrintHelper printHelper = null;
         var properties = new Dictionary <string, string>
         {
             { "class", "Forms9Patch.UWP.PrintService" },
             { "method", "PrintAsync" },
         };
         try
         {
             if (webView.Source is HtmlWebViewSource htmlSource && !string.IsNullOrWhiteSpace(htmlSource.Html))
             {
                 properties["line"] = "47";
                 printHelper        = new WebViewPrintHelper(htmlSource.Html, htmlSource.BaseUrl, jobName);
             }
             else if (webView.Source is UrlWebViewSource urlSource && !string.IsNullOrWhiteSpace(urlSource.Url))
             {
                 properties["line"] = "53";
                 printHelper        = new WebViewPrintHelper(urlSource.Url, jobName);
             }
示例#2
0
 public void Print(Xamarin.Forms.WebView webView, string jobName)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (string.IsNullOrWhiteSpace(jobName))
         {
             jobName = Forms9Patch.ApplicationInfoService.Name;
         }
         WebViewPrintHelper printHelper = null;
         if (Platform.GetRenderer(webView) is WebViewRenderer renderer && renderer.Control is Windows.UI.Xaml.Controls.WebView nativeWebView)
         {
             printHelper = new WebViewPrintHelper(nativeWebView, jobName);
         }
示例#3
0
 public Task PrintAsync(Xamarin.Forms.WebView webView, string jobName)
 {
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (string.IsNullOrWhiteSpace(jobName))
         {
             jobName = Forms9Patch.ApplicationInfoService.Name;
         }
         WebViewPrintHelper printHelper = null;
         if (webView.Source is HtmlWebViewSource htmlSource && !string.IsNullOrWhiteSpace(htmlSource.Html))
         {
             printHelper = new WebViewPrintHelper(htmlSource.Html, htmlSource.BaseUrl, jobName);
         }