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)
            {
                
            }
        }
相关推荐
小二·12 小时前
MyBatis基础入门《十五》分布式事务实战:Seata + MyBatis 实现跨服务数据一致性
分布式·wpf·mybatis
helloworddm21 小时前
UnregisterManyAsync
wpf
军训猫猫头1 天前
3.NModbus4 长距离多设备超时 C# + WPF 完整示例
c#·.net·wpf·modbus
轻竹办公PPT1 天前
上传PDF直接生成PPT,适合工作汇报和总结场景
python·pdf·powerpoint
Aevget1 天前
DevExpress WPF中文教程:Data Grid - 如何绑定到有限制的自定义服务(一)?
ui·.net·wpf·devexpress·ui开发·wpf界面控件
非凡ghost1 天前
FlexiPDF(专业PDF编辑软件)
windows·学习·pdf·软件需求
Macbethad1 天前
半导体设备工厂自动化软件技术方案
wpf·智能硬件
Macbethad1 天前
半导体设备报警诊断程序技术方案
wpf·智能硬件
xinyu_Jina1 天前
PaperStudio:WYSIWYG文档的Web实现——从CSS Print到客户端PDF生成的技术解析
前端·css·pdf
Macbethad2 天前
技术方案:工业控制系统架构设计
wpf