网站首页 全球最实用的IT互联网站!

人工智能P2P分享Wind搜索发布信息网站地图标签大全

当前位置:诺佳网 > 软件工程 > 后端开发 > .Net >

.Net PdfiumViewer 打印时无法渲染电子签名问题的解

时间:2024-10-14 11:44

人气:

作者:admin

标签:

导读:需要修改源代码或直接反编译动态库修改 PdfPrintDocument.RenderPage 方法,本文仅介绍修改动态库。...

转载请标明原出处:https://www.cnblogs.com/crpfs/p/18463735

本文修改的动态库是从如下的 NuGet 包中获取的:

如果使用的是 Visual Studio 中的 NuGet 包管理器获取的,则其动态库(.dll)一般会存放在:

.\packages\PdfiumViewer.2.13.0.0\lib\net20\PdfiumViewer.dll

另外,还需要反编译动态库的工具:dnSpy,本文使用的是 dnSpy 作者弃坑后另一位佬接手重生的项目 dnSpyEx

① 将动态库拖入 dnSpy,展开如下命名空间:

② 找到 PdfPrintDocument 类,展开,再找到 RenderPage 方法:

③ 右键 ==> 修改方法(C#),修改最后一行代码:

// 原本的代码
// this._document.Render(page, e.Graphics, e.Graphics.DpiX, e.Graphics.DpiY, new Rectangle(PdfPrintDocument.AdjustDpi((double)e.Graphics.DpiX, left), PdfPrintDocument.AdjustDpi((double)e.Graphics.DpiY, top), PdfPrintDocument.AdjustDpi((double)e.Graphics.DpiX, num3), PdfPrintDocument.AdjustDpi((double)e.Graphics.DpiY, num4)), PdfRenderFlags.ForPrinting | PdfRenderFlags.Annotations);

// 修改后的代码
using (Image image = this._document.Render(page, PdfPrintDocument.AdjustDpi((double)e.Graphics.DpiX, (double)e.PageBounds.Width), PdfPrintDocument.AdjustDpi((double)e.Graphics.DpiX, (double)e.PageBounds.Height), e.Graphics.DpiX, e.Graphics.DpiY, PdfRotation.Rotate0, PdfRenderFlags.ForPrinting | PdfRenderFlags.Annotations))
{
e.Graphics.DrawImageUnscaled(image, e.PageBounds.Location);
}

④ 在菜单栏选择 文件 ==> 保存模块,直接点确定即可重新编译动态库。

注意:会直接覆盖原先的动态库,如需要则注意备份。

温馨提示:以上内容整理于网络,仅供参考,如果对您有帮助,留下您的阅读感言吧!
相关阅读
本类排行
相关标签
本类推荐

CPU | 内存 | 硬盘 | 显卡 | 显示器 | 主板 | 电源 | 键鼠 | 网站地图

Copyright © 2025-2035 诺佳网 版权所有 备案号:赣ICP备2025066733号
本站资料均来源互联网收集整理,作品版权归作者所有,如果侵犯了您的版权,请跟我们联系。

关注微信