利用c#怎么实现给pdf文件添加数字签名

  介绍

本篇文章给大家分享的是有关利用c#怎么实现给pdf文件添加数字签名,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

步骤1:新建一个pdf文档并加载一个pdf证书

//新建一个pdf文档对象,再添加一个新页面。   PdfDocument  doc =, new  PdfDocument ();   doc.Pages.Add ();//加载一个PDF证书,,,,,,   PdfCertificate  cert =, new  PdfCertificate (@" C: \ \用户管理员桌面\ \ gary.pfx",,“e-iceblue");

步骤2:添加数字签名并设置数字签名的位置

//添加数字签名   var  signature =, new  PdfSignature(医生,,doc.Pages[0],,证书,,“Requestd1");//设置数字签名的位置   时间=signature.Bounds  new  RectangleF (new  PointF (280,, 600), new  SizeF (260,, 90));

步骤3:设置显示文本属性

signature.IsTag =,真的,以前

步骤4:填充数字签名的内容

signature.DigitalSignerLable =,“Digitally  signed  by";   时间=signature.DigitalSigner “Gary  for  Test";      时间=signature.DistinguishedName “DN:“;   时间=signature.LocationInfoLabel “位置:“;   时间=signature.LocationInfo “London";      时间=signature.ReasonLabel “原因:,“;   时间=signature.Reason “Le  document  est  certifie";      时间=signature.DateLabel “日期:,“;   时间=signature.Date  DateTime.Now;      时间=signature.ContactInfoLabel “接触:,“;   时间=signature.ContactInfo “123456789“;      时间=signature.Certificated 假;      signature.ConfigGraphicType =, ConfiguerGraphicType.TextSignInformation;

步骤5:设置数字签名的文档权限

signature.DocumentPermissions =, PdfCertificationFlags.ForbidChanges;

步骤6:将文档以PDF格式保存到文件夹中

//保存文档   doc.SaveToFile (“sample.pdf");//打开文档   System.Diagnostics.Process.Start (“sample.pdf");

以上就是利用c#怎么实现给pdf文件添加数字签名,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。

利用c#怎么实现给pdf文件添加数字签名