WPF 使用PdfiumViewer实现PDF预览与打印

1.引用Nuget包:PdfiumViewer

2.Xaml代码,需要使用标签,可能这个包是为winform设计的。

    xmlns:pdfium="clr-namespace:PdfiumViewer;assembly=PdfiumViewer"

    
        
    

3.后台代码,非常简单,绑定一下PDF文件路径即可。

        public PrintingPDF(string PDFPath)
        {
            InitializeComponent();

            try
            {
                var document = PdfDocument.Load(PDFPath);
                pdfViewer.Document = document;
            }
            catch (Exception ex)
            {
                
            }
        }

你可能感兴趣的:(WPF,wpf,pdf)