반응형
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";
}
}
반응형
'[====== Development ======] > C#' 카테고리의 다른 글
C# List Custom Comparison (0) | 2022.02.16 |
---|---|
WPF 콘트롤의 부모컴포넌트부터의 자표값 구하는법 (0) | 2022.02.15 |
WPF DataGrid의 RowDetailsTemplate 을 가져오는 방법 (0) | 2021.12.20 |
[WPF] ListView 컬럼 순서 변경 (0) | 2021.11.23 |
[WPF] ListView에 text 컬럼과 UserControl 컬럼 추가 (0) | 2021.11.23 |