Aspose.PDF for .NET(點擊下載)是一種高PDF處理和解析API,用於在跨平臺應用程序中執行文檔管理和操做任務。API能夠輕鬆用於生成、修改、轉換、渲染、保護和打印PDF文檔,而無需使用Adobe Acrobat。此外,API還提供PDF壓縮選項,表格建立和操做,圖形和圖像功能,普遍的超連接功能,印章和水印任務,擴展的安全控制和自定義字體處理。安全
在接下來的系列教程中,將爲開發者帶來Aspose.PDF for .NET的一系列使用教程,例如進行文檔間的轉換,如何標記PDF文件,如何使用表單和圖表等等。字體
Aspose.PDF for .NET支持使用SignatureField類對PDF文件進行數字簽名的功能,在簽名文檔時,能夠爲其設置圖像SignatureAppearance。如今,此API還提供了提取簽名信息以及與簽名字段關聯的圖像的功能。spa
爲了提取簽名信息,ExtractImage(..)方法引入了SignatureField該類。請查看如下代碼片斷,其中演示了從SignatureField對象中提取圖像的步驟:orm
// 文檔目錄的路徑。 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); } } } } } }