반응형

1. Nuget Package에서 CefCharp.Wpf 추가

Page : http://cefsharp.github.io/

Nuget : https://www.nuget.org/packages/CefSharp.Wpf/96.0.180/ReportAbuse

    internal class DownloadHandler : IDownloadHandler
    {
        public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
        {
            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    callback.Continue(downloadItem.SuggestedFileName, showDialog: true);
                }
            }
        }

        public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
        {
            if (downloadItem.IsComplete)
            {
                if (@downloadItem.FullPath != "")
                {
                    Console.WriteLine(@downloadItem.FullPath);
                }
            }
        }
    }
    public partial class MainWindow : Window
    {
        private CefSharp.Wpf.ChromiumWebBrowser webReportPreview;

        public MainWindow()
        {
            InitializeComponent();

            webReportPreview = new CefSharp.Wpf.ChromiumWebBrowser();
            webReportPreview.DownloadHandler = new DownloadHandler();
            grdPdfview.Children.Add(webReportPreview);
        }

        private void btnOpen_Click(object sender, RoutedEventArgs e)
        {
            webReportPreview.Address = @"C:\PDF\test.pdf";
        }
    }

 

반응형

+ Recent posts