翻譯|使用教程|編輯:李顯亮|2019-09-19 11:40:39.870|閱讀 569 次
概述:Aspose.PDF for .NET是一種高PDF處理和解析API,用于在跨平臺應用程序中執行文檔管理和操作任務。Aspose.PDF for .NET支持使用SignatureField類對PDF文件進行數字簽名的功能,本文將介紹如何提取圖像和簽名信息。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.PDF for .NET是一種高PDF處理和解析API,用于在跨平臺應用程序中執行文檔管理和操作任務。API可以輕松用于生成、修改、轉換、渲染、保護和打印PDF文檔,而無需使用Adobe Acrobat。此外,API還提供PDF壓縮選項,表格創建和操作,圖形和圖像功能,廣泛的超鏈接功能,印章和水印任務,擴展的安全控制和自定義字體處理。
在接下來的系列教程中,將為開發者帶來Aspose.PDF for .NET的一系列使用教程,例如進行文檔間的轉換,如何標記PDF文件,如何使用表單和圖表等等。
>>Aspose.PDF for .NET更新至最新版v19.9,歡迎下載體驗。
Aspose.PDF for .NET支持使用SignatureField類對PDF文件進行數字簽名的功能,在簽名文檔時,可以為其設置圖像SignatureAppearance。現在,此API還提供了提取簽名信息以及與簽名字段關聯的圖像的功能。
為了提取簽名信息,ExtractImage(..)方法引入了SignatureField該類。請查看以下代碼片段,其中演示了從SignatureField對象中提取圖像的步驟:
// 文檔目錄的路徑。 string dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures(); string input = dataDir+ @"ExtractingImage.pdf"; using (Document pdfDocument = new Document(input)) { foreach (Field field in pdfDocument.Form) { SignatureField sf = field as SignatureField; if (sf != null) { string outFile = dataDir+ @"output_out.jpg"; using (Stream imageStream = sf.ExtractImage()) { if (imageStream != null) { using (System.Drawing.Image image = Bitmap.FromStream(imageStream)) { image.Save(outFile, System.Drawing.Imaging.ImageFormat.Jpeg); } } } } } }
Aspose.PDF for .NET支持使用SignatureField該類對PDF文件進行數字簽名的功能。目前還可以確定證書的有效性,無法提取整個證書,可以提取的信息是公鑰,指紋,發行者等。
為了提取簽名信息,該ExtractCertificate(..)方法引入了SignatureField該類。請查看以下代碼片段,其中演示了從SignatureField對象中提取證書的步驟:
// 文檔目錄的路徑。 string dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures(); string input = dataDir + "ExtractSignatureInfo.pdf"; using (Document pdfDocument = new Document(input)) { foreach (Field field in pdfDocument.Form) { SignatureField sf = field as SignatureField; if (sf != null) { Stream cerStream = sf.ExtractCertificate(); if (cerStream != null) { using (cerStream) { byte[] bytes = new byte[cerStream.Length]; using (FileStream fs = new FileStream(dataDir + @"input.cer", FileMode.CreateNew)) { cerStream.Read(bytes, 0, bytes.Length); fs.Write(bytes, 0, bytes.Length); } } } } } }
推薦閱讀:【干貨來襲】Aspose.PDF示例資源最全分享!
*悅滿中秋 · 購享好禮,現在購買Aspose系列產品即可領取精美禮品喲,更多活動詳情可了解哦~
ASPOSE技術交流QQ群(642018183)已開通,各類資源及時分享,歡迎交流討論!
掃描關注“慧聚IT”微信公眾號,及時獲取更多產品最新動態及最新資訊
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn