原創|使用教程|編輯:龔雪|2014-06-13 10:56:44.000|閱讀 8271 次
概述:如何通過代碼清除PDF文件上的數字簽名。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
PDF (正面)上的數字簽名是可以去掉的。可以將PDF文件上所有數字簽名都去掉,也可以單獨去掉某個特定的數字簽名。以往的方式簡單粗暴,不僅去掉了簽名,而且簽字處的空格也無法保留。今天要介紹的這種方法不僅可以清除簽字,還能保留簽字處空白,以便下次重新進行數字簽名。
PdfFileSignature類的RemoveSignature method允許用戶從PDF文件清除數字簽名。該方法的原理就是把簽名當做一個輸入。要么直接確定一個簽名,要么把所有簽名都清除。獲取這些簽名的就是GetSignNames method。
下列代碼片段能告訴你具體怎么做:
C#
// Create PdfFileSignature object PdfFileSignature pdfSign = new PdfFileSignature(); // Open PDF document pdfSign.BindPdf("input.pdf"); // Get list of signature names IList names = pdfSign.GetSignNames(); // Remove all the signatures from the PDF file for(int index = 0; index < names.Count; index++) { pdfSign.RemoveSignature((string)names[index]); } // Save updated PDF file pdfSign.Save("output.pdf");
VB.NET
' Create PdfFileSignature object Dim pdfSign As New PdfFileSignature() ' Open PDF document pdfSign.BindPdf("input.pdf") ' Get list of signature names Dim names As IList = pdfSign.GetSignNames() ' Remove all the signatures from the PDF file For index As Integer = 0 To names.Count - 1 pdfSign.RemoveSignature(CStr(names(index))) Next index ' Save updated PDF file pdfSign.Save("output.pdf")
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網