文檔首頁(yè)>>Aspose.PDF使用教程>>Aspose.Pdf使用教程:獲取附件信息
Aspose.Pdf使用教程:獲取附件信息
FileSpecification對(duì)象能提供包括名稱、描述、MIMEType和參數(shù)在內(nèi)的附件屬性信息。前三個(gè)屬性從他們的名字可以很明顯地看出他們的作用,而參數(shù)屬性提供了有關(guān)文件的參數(shù)信息。這些參數(shù)包括校驗(yàn),創(chuàng)建日期,審核日期和大小。為了獲得這些參數(shù),首先需要確保Params參數(shù)屬性不為空。
你可以從Document文件對(duì)象的EmbeddedFiles Collection集合中獲取FileSpecification對(duì)象。 這個(gè)EmbeddedFiles集合包含PDF文檔的所有附件。
獲取附件信息的代碼示例如下:
C#
//open document Document pdfDocument = new Document("input.pdf"); //get particular embedded file FileSpecification fileSpecification = pdfDocument.EmbeddedFiles[1]; //get the file properties Console.WriteLine("Name: {0}", fileSpecification.Name); Console.WriteLine("Description: {0}", fileSpecification.Description); Console.WriteLine("Mime Type: {0}", fileSpecification.MIMEType); //check if parameter object contains the parameters if (fileSpecification.Params != null) { Console.WriteLine("CheckSum: {0}", fileSpecification.Params.CheckSum); Console.WriteLine("Creation Date: {0}", fileSpecification.Params.CreationDate); Console.WriteLine("Modification Date: {0}", fileSpecification.Params.ModDate); Console.WriteLine("Size: {0}", fileSpecification.Params.Size); }VB.NET
'open document Dim pdfDocument As New Document("input.pdf") 'get particular embedded file Dim fileSpecification As FileSpecification = pdfDocument.EmbeddedFiles(1) 'get the file properties Console.WriteLine("Name: {0}", fileSpecification.Name) Console.WriteLine("Description: {0}", fileSpecification.Description) Console.WriteLine("Mime Type: {0}", fileSpecification.MIMEType) 'check if parameter object contains the parameters If fileSpecification.Params IsNot Nothing Then Console.WriteLine("CheckSum: {0}", fileSpecification.Params.CheckSum) Console.WriteLine("Creation Date: {0}", fileSpecification.Params.CreationDate) Console.WriteLine("Modification Date: {0}", fileSpecification.Params.ModDate) Console.WriteLine("Size: {0}", fileSpecification.Params.Size) End If