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

1.引用Nuget包:PdfiumViewer

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

XML 复制代码
    xmlns:pdfium="clr-namespace:PdfiumViewer;assembly=PdfiumViewer"

    <WindowsFormsHost>
        <pdfium:PdfViewer x:Name="pdfViewer" Width="300" Height="300"/>
    </WindowsFormsHost>

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

cs 复制代码
        public PrintingPDF(string PDFPath)
        {
            InitializeComponent();

            try
            {
                var document = PdfDocument.Load(PDFPath);
                pdfViewer.Document = document;
            }
            catch (Exception ex)
            {
                
            }
        }
相关推荐
uuai1 天前
vue导出pdf
前端·vue.js·pdf
Sour1 天前
产品说明书翻译成英文怎么保留排版?PDF、Word、外贸资料处理清单
pdf·word
winfredzhang2 天前
为长阅读而生:我做了一个「安静」的 PDF 阅读器
pdf·html
100个铜锣烧2 天前
文档处理管线:从PDF到向量——RAG系统的“第一道关口”
pdf
精明的身影2 天前
深入WPF -- Dispatcher(补)
wpf
asdzx672 天前
在 React 中轻松实现 PDF 转 Word:纯前端 WASM 方案实战
前端·react.js·pdf
Lyn_Li3 天前
扫描 PDF 歪了怎么办?用 6 种检测方法做本地批量扶正(附开源工具)
python·pdf·ocr·tesseract·开源工具·文档处理·本地处理·扫描件纠偏
云中飞鸿3 天前
该如何进行WPF界面设计
wpf
Mr.Daozhi3 天前
从零构建 AI 学术论文助手(四):PDF.js 实时截图 + Gemini 视觉分析
javascript·人工智能·pdf·canvas·pdf.js·gemini