Пример #1
0
        public void Print(string html, string jobName)
        {
            _activityIndicatorPopup = ActivityIndicatorPopup.Create();
            var taskCompletionSource = new TaskCompletionSource <ToFileResult>();

            InnerPrint(taskCompletionSource, html, jobName);
        }
Пример #2
0
        public Task PrintAsync(string html, string jobName, FailAction failAction = FailAction.ShowAlert)
        {
            _activityIndicatorPopup = ActivityIndicatorPopup.Create();
            var taskCompletionSource = new TaskCompletionSource <ToFileResult>();

            InnerPrint(taskCompletionSource, html, jobName, failAction);
            return(taskCompletionSource.Task);
        }
Пример #3
0
        async Task OnPageFinished(Android.Webkit.WebView webView, string jobName, PageSize pageSize, PageMargin margin, TaskCompletionSource <ToFileResult> taskCompletionSource)
        {
            if (string.IsNullOrWhiteSpace(jobName))
            {
                jobName = Forms9Patch.ApplicationInfoService.Name;
            }
            var printMgr = (PrintManager)Settings.Context.GetSystemService(Context.PrintService);
            await Task.Delay(1000); // allow a bit more time for the layout to complete;

            printMgr.Print(jobName, webView.CreatePrintDocumentAdapter(jobName), null);
            _activityIndicatorPopup.Dispose();
            _activityIndicatorPopup = null;
            taskCompletionSource.SetResult(new ToFileResult(false, jobName));
            webView.Dispose();
        }