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)
            {
                
            }
        }
相关推荐
云中飞鸿1 天前
WPF分哪几块
wpf
newbe365241 天前
我们如何使用 impeccable 优化前端界面设计与实现稳定性
前端·人工智能·分布式·github·aigc·wpf
wenxin77wx2 天前
3步部署OlmOCR:一行命令将PDF转为LLM训练数据
pdf·- olmocr
2501_930707782 天前
PDF 转 Markdown:在线与离线转换完整指南
pdf
ShiXZ2132 天前
PDF-OCR文件识别篇(七):数据入库
java·pdf·json·ocr·springboot
hong78172 天前
西门子触摸屏PROSAVE传输PDF组件没有选项
pdf·触摸屏·西门子
王莎莎-MinerU2 天前
当 RealDocBench 开始追问字段级问答,MinerU 为什么更适合做知识库与科研 Agent 的文档验收层
大数据·人工智能·算法·pdf·ocr
weixin_3975740919 天前
PDF复杂表格的1:1还原引擎:跨页表格自动拼接技术实战
大数据·人工智能·pdf
Metaphor69219 天前
使用 Python 将 PDF 转换为 HTML
python·pdf·html
2601_9618451519 天前
粉笔行测5000题电子版|pdf|解析
pdf·新媒体运营·github·个人开发·内容运营·规格说明书·极限编程