Exemple #1
0
        public async void PrintUWpAsync(string htmlSource)
        {
            ViewToPrint.NavigateToString(htmlSource);
            if (PrintDoc != null)
            {
                printDoc.GetPreviewPage -= PrintDoc_GetPreviewPage;
                printDoc.Paginate       -= PrintDoc_Paginate;
                printDoc.AddPages       -= PrintDoc_AddPages;
            }
            this.printDoc = new PrintDocument();
            try
            {
                printDoc.GetPreviewPage += PrintDoc_GetPreviewPage;
                printDoc.Paginate       += PrintDoc_Paginate;
                printDoc.AddPages       += PrintDoc_AddPages;

                bool showprint = await PrintManager.ShowPrintUIAsync();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
            PrintDoc = null;
            GC.Collect();
        }
Exemple #2
0
        private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Windows.UI.Xaml.Controls.WebView wv = d as Windows.UI.Xaml.Controls.WebView;

            var content = e.NewValue as string;

            if (string.IsNullOrEmpty(content))
            {
                return;
            }

            wv?.NavigateToString(content);
        }