Exemplo n.º 1
0
        void InnerPrint(TaskCompletionSource <ToFileResult> taskCompletionSource, string html, string jobName, FailAction failAction)
        {
            try
            {
                var size    = new Size(8.5, 11);
                var webView = new Android.Webkit.WebView(Android.App.Application.Context);
                webView.Settings.JavaScriptEnabled = true;
                webView.Settings.DomStorageEnabled = true;
#pragma warning disable CS0618 // Type or member is obsolete
                webView.DrawingCacheEnabled = true;
#pragma warning restore CS0618 // Type or member is obsolete
                webView.SetLayerType(LayerType.Software, null);

                //webView.Layout(0, 0, (int)((size.Width - 0.5) * 72), (int)((size.Height - 0.5) * 72));
                webView.Layout(36, 36, (int)((PageSize.Default.Width - 0.5) * 72), (int)((PageSize.Default.Height - 0.5) * 72));

                webView.SetWebViewClient(new WebViewCallBack(taskCompletionSource, jobName, PageSize.Default, null, OnPageFinished));
                webView.LoadData(html, "text/html; charset=utf-8", "UTF-8");
            }
            catch (Exception e)
            {
                if (failAction == FailAction.ShowAlert)
                {
                    using (Forms9Patch.Alert.Create("Print Failure", e.Message)) { }
                }
                else if (failAction == FailAction.ThrowException)
                {
                    throw e;
                }
            }
        }
Exemplo n.º 2
0
        void InnerPrint(TaskCompletionSource <ToFileResult> taskCompletionSource, string html, string jobName)
        {
            var size    = new Size(8.5, 11);
            var webView = new Android.Webkit.WebView(Android.App.Application.Context);

            webView.Settings.JavaScriptEnabled = true;
            webView.Settings.DomStorageEnabled = true;
#pragma warning disable CS0618 // Type or member is obsolete
            webView.DrawingCacheEnabled = true;
#pragma warning restore CS0618 // Type or member is obsolete
            webView.SetLayerType(LayerType.Software, null);

            webView.Layout(0, 0, (int)((size.Width - 0.5) * 72), (int)((size.Height - 0.5) * 72));

            webView.SetWebViewClient(new WebViewCallBack(taskCompletionSource, jobName, OnPageFinished));
            webView.LoadData(html, "text/html; charset=utf-8", "UTF-8");
        }
Exemplo n.º 3
0
        public void ConvertHTMLtoPDF(PDFToHtml _PDFToHtml)
        {
            try
            {
                var webpage = new Android.Webkit.WebView(Android.App.Application.Context);
                webpage.Settings.JavaScriptEnabled = true;

#pragma warning disable CS0618 // Type or member is obsolete
                webpage.DrawingCacheEnabled = true;
#pragma warning restore CS0618 // Type or member is obsolete

                webpage.SetLayerType(LayerType.Software, null);
                webpage.Layout(0, 0, (int)_PDFToHtml.PageWidth, (int)_PDFToHtml.PageHeight);
                webpage.LoadData(_PDFToHtml.HTMLString, "text/html; charset=utf-8", "UTF-8");
                webpage.SetWebViewClient(new WebViewCallBack(_PDFToHtml));
            }
            catch
            {
                _PDFToHtml.Status = PDFEnum.Failed;
            }
        }