
public class PdfAttachmentCollection : Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
public __gc class PdfAttachmentCollection : public Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase*
public ref class PdfAttachmentCollection : public Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase^
'Declaration Public Class PdfAttachmentCollection Inherits Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
Начиная с PDF 1.7, документы PDF могут указывать, как пользовательский интерфейс приложения просмотра представляет коллекции вложений файлов (портфолио), где вложения связаны по структуре или содержанию. Такая презентация называется переносной коллекцией. Целью переносимых коллекций является представление, сортировка и поиск коллекций связанных документов, таких как архивы электронной почты, коллекции фотографий и т. д. Если в PDF документе присутствует вложение, пользовательский интерфейс представляет документ как коллекцию вложений.
Начиная с PDF 1.7 ExtensionLevel 3, коллекция вложений может содержать папки для организации файлов в иерархическую структуру. Структура представлена деревом с одной корневой папкой (RootFolder), выступающей в качестве общего предка для всех остальных папок и файлов в коллекции.
Вот пример, показывающий, как получить информацию о вложениях PDF документа:
''' <summary> ''' Prints the portfolio structure. ''' </summary> ''' <param name="pdfFilename">The PDF filename.</param> Public Shared Sub PrintPortfolioStructure(pdfFilename As String) ' open PDF document in read-only mode Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename, True) ' if PDF document does not contain portfolio If document.Attachments Is Nothing Then System.Console.WriteLine("Document does not have attachments (portfolio).") Return End If ' print initial view mode System.Console.WriteLine(String.Format("Initial View Mode = {0}", document.Attachments.View)) ' print colors information If document.Attachments.Colors IsNot Nothing Then PrintPortfolioColors(document.Attachments.Colors) End If ' print portfolio schema If document.Attachments.Schema IsNot Nothing Then PrintPortfolioSchema(document.Attachments.Schema) End If ' print portfolio sort settings If document.Attachments.Sort IsNot Nothing Then PrintPortfolioSort(document.Attachments.Sort) End If ' print portfolio splitter bar settings If document.Attachments.SplitterBar IsNot Nothing Then PrintPortfolioSplitterBar(document.Attachments.SplitterBar) End If ' print portfolio folders and files If document.Attachments.RootFolder IsNot Nothing Then System.Console.WriteLine("Folder structure:") PrintFolderStructure(document.Attachments.RootFolder, " ") Else System.Console.WriteLine("Files:") PrintFileInfo(document.Attachments.GetFiles(""), " ") End If End Using End Sub ''' <summary> ''' Prints the folder structure. ''' </summary> ''' <param name="folder">The PDF attachment folder.</param> ''' <param name="padding">Padding.</param> Private Shared Sub PrintFolderStructure(folder As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder, padding As String) System.Console.WriteLine(String.Format("{0}Folder: {1}", padding, folder.Name)) padding += " " PrintFileInfo(folder.Files, padding) Dim subFolders As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder() = folder.Folders If subFolders IsNot Nothing Then For Each subFolder As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder In subFolders PrintFolderStructure(subFolder, padding) Next End If End Sub ''' <summary> ''' Prints the portfolio splitter bar information. ''' </summary> ''' <param name="splitterBar">The splitter bar.</param> Private Shared Sub PrintPortfolioSplitterBar(splitterBar As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSplitterBar) System.Console.WriteLine("Splitter Bar:") System.Console.WriteLine(String.Format(" Direction = {0}", splitterBar.Direction)) System.Console.WriteLine(String.Format(" Position = {0}", splitterBar.Position)) End Sub ''' <summary> ''' Prints an information for specified files. ''' </summary> ''' <param name="fileSpecs">The PDF embedded file specifications.</param> ''' <param name="padding">Padding.</param> Private Shared Sub PrintFileInfo(fileSpecs As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification(), padding As String) For Each fileSpec As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification In fileSpecs System.Console.WriteLine(String.Format("{0}File: {1}", padding, fileSpec.Filename)) System.Console.WriteLine(String.Format("{0} CompressedSize = {1}", padding, fileSpec.CompressedSize)) System.Console.WriteLine(String.Format("{0} UncompressedSize = {1}", padding, fileSpec.UncompressedSize)) System.Console.WriteLine(String.Format("{0} Compression = {1}", padding, fileSpec.Compression)) System.Console.WriteLine(String.Format("{0} CreationDate = {1}", padding, fileSpec.CreationDate)) System.Console.WriteLine(String.Format("{0} ModificationDate = {1}", padding, fileSpec.ModificationDate)) System.Console.WriteLine(String.Format("{0} Description = {1}", padding, fileSpec.Description)) System.Console.WriteLine(String.Format("{0} HasThumbnail = {1}", padding, fileSpec.Thumbnail IsNot Nothing)) If fileSpec.DataFields IsNot Nothing Then System.Console.WriteLine(" DataFields:") For Each name As String In fileSpec.DataFields.Keys System.Console.WriteLine(String.Format(" {0}={1}", name, fileSpec.DataFields(name).DataAsString)) Next End If Next End Sub ''' <summary> ''' Prints the portfolio sort properties. ''' </summary> ''' <param name="sort">The PDF attachment collection sort properties.</param> Private Shared Sub PrintPortfolioSort(sort As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSort) System.Console.WriteLine("Sort:") System.Console.WriteLine(" Field names:") Dim fieldNames As String() = sort.FieldNames For i As Integer = 0 To fieldNames.Length - 1 System.Console.WriteLine(" {0}: {1}", i, fieldNames(i)) Next System.Console.WriteLine(" Ascending orders:") Dim ascendingOrders As Boolean() = sort.AscendingOrders For i As Integer = 0 To ascendingOrders.Length - 1 System.Console.WriteLine(" {0}: {1}", i, ascendingOrders(i)) Next End Sub ''' <summary> ''' Prints the portfolio schema. ''' </summary> ''' <param name="schema">The PDF attachment collection schema.</param> Private Shared Sub PrintPortfolioSchema(schema As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchema) System.Console.WriteLine("Schema:") For Each key As String In schema.Keys System.Console.WriteLine(String.Format(" {0}:", key)) Dim field As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField = schema(key) System.Console.WriteLine(" DataType = {0}", field.DataType) System.Console.WriteLine(" DisplayedName = {0}", field.DisplayedName) System.Console.WriteLine(" IsSupportsEditing = {0}", field.IsSupportsEditing) System.Console.WriteLine(" IsVisible = {0}", field.IsVisible) System.Console.WriteLine(" Order = {0}", field.Order) Next End Sub ''' <summary> ''' Prints the portfolio colors information. ''' </summary> ''' <param name="presentationColors">The presentation colors.</param> Private Shared Sub PrintPortfolioColors(presentationColors As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfPresentationColors) System.Console.WriteLine("Colors:") System.Console.WriteLine(String.Format(" Background = {0}", presentationColors.Background)) System.Console.WriteLine(String.Format(" CardBackground = {0}", presentationColors.CardBackground)) System.Console.WriteLine(String.Format(" CardBorder = {0}", presentationColors.CardBorder)) System.Console.WriteLine(String.Format(" PrimaryText = {0}", presentationColors.PrimaryText)) System.Console.WriteLine(String.Format(" SecondaryText = {0}", presentationColors.SecondaryText)) End Sub
/// <summary> /// Prints the portfolio structure. /// </summary> /// <param name="pdfFilename">The PDF filename.</param> public static void PrintPortfolioStructure(string pdfFilename) { // open PDF document in read-only mode using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename, true)) { // if PDF document does not contain portfolio if (document.Attachments == null) { System.Console.WriteLine("Document does not have attachments (portfolio)."); return; } // print initial view mode System.Console.WriteLine(string.Format("Initial View Mode = {0}", document.Attachments.View)); // print colors information if (document.Attachments.Colors != null) PrintPortfolioColors(document.Attachments.Colors); // print portfolio schema if (document.Attachments.Schema != null) PrintPortfolioSchema(document.Attachments.Schema); // print portfolio sort settings if (document.Attachments.Sort != null) PrintPortfolioSort(document.Attachments.Sort); // print portfolio splitter bar settings if (document.Attachments.SplitterBar != null) PrintPortfolioSplitterBar(document.Attachments.SplitterBar); // print portfolio folders and files if (document.Attachments.RootFolder != null) { System.Console.WriteLine("Folder structure:"); PrintFolderStructure(document.Attachments.RootFolder, " "); } else { System.Console.WriteLine("Files:"); PrintFileInfo(document.Attachments.GetFiles(""), " "); } } } /// <summary> /// Prints the folder structure. /// </summary> /// <param name="folder">The PDF attachment folder.</param> /// <param name="padding">Padding.</param> private static void PrintFolderStructure( Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder folder, string padding) { System.Console.WriteLine(string.Format("{0}Folder: {1}", padding, folder.Name)); padding += " "; PrintFileInfo(folder.Files, padding); Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder[] subFolders = folder.Folders; if (subFolders != null) { foreach (Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder subFolder in subFolders) PrintFolderStructure(subFolder, padding); } } /// <summary> /// Prints the portfolio splitter bar information. /// </summary> /// <param name="splitterBar">The splitter bar.</param> private static void PrintPortfolioSplitterBar( Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSplitterBar splitterBar) { System.Console.WriteLine("Splitter Bar:"); System.Console.WriteLine(string.Format(" Direction = {0}", splitterBar.Direction)); System.Console.WriteLine(string.Format(" Position = {0}", splitterBar.Position)); } /// <summary> /// Prints an information for specified files. /// </summary> /// <param name="fileSpecs">The PDF embedded file specifications.</param> /// <param name="padding">Padding.</param> private static void PrintFileInfo( Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification[] fileSpecs, string padding) { foreach (Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification fileSpec in fileSpecs) { System.Console.WriteLine(string.Format("{0}File: {1}", padding, fileSpec.Filename)); System.Console.WriteLine(string.Format("{0} CompressedSize = {1}", padding, fileSpec.CompressedSize)); System.Console.WriteLine(string.Format("{0} UncompressedSize = {1}", padding, fileSpec.UncompressedSize)); System.Console.WriteLine(string.Format("{0} Compression = {1}", padding, fileSpec.Compression)); System.Console.WriteLine(string.Format("{0} CreationDate = {1}", padding, fileSpec.CreationDate)); System.Console.WriteLine(string.Format("{0} ModificationDate = {1}", padding, fileSpec.ModificationDate)); System.Console.WriteLine(string.Format("{0} Description = {1}", padding, fileSpec.Description)); System.Console.WriteLine(string.Format("{0} HasThumbnail = {1}", padding, fileSpec.Thumbnail != null)); if (fileSpec.DataFields != null) { System.Console.WriteLine(" DataFields:"); foreach (string name in fileSpec.DataFields.Keys) { System.Console.WriteLine(string.Format(" {0}={1}", name, fileSpec.DataFields[name].DataAsString)); } } } } /// <summary> /// Prints the portfolio sort properties. /// </summary> /// <param name="sort">The PDF attachment collection sort properties.</param> private static void PrintPortfolioSort( Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSort sort) { System.Console.WriteLine("Sort:"); System.Console.WriteLine(" Field names:"); string[] fieldNames = sort.FieldNames; for (int i = 0; i < fieldNames.Length; i++) System.Console.WriteLine(" {0}: {1}", i, fieldNames[i]); System.Console.WriteLine(" Ascending orders:"); bool[] ascendingOrders = sort.AscendingOrders; for (int i = 0; i < ascendingOrders.Length; i++) System.Console.WriteLine(" {0}: {1}", i, ascendingOrders[i]); } /// <summary> /// Prints the portfolio schema. /// </summary> /// <param name="schema">The PDF attachment collection schema.</param> private static void PrintPortfolioSchema( Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchema schema) { System.Console.WriteLine("Schema:"); foreach (string key in schema.Keys) { System.Console.WriteLine(string.Format(" {0}:", key)); Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField field = schema[key]; System.Console.WriteLine(" DataType = {0}", field.DataType); System.Console.WriteLine(" DisplayedName = {0}", field.DisplayedName); System.Console.WriteLine(" IsSupportsEditing = {0}", field.IsSupportsEditing); System.Console.WriteLine(" IsVisible = {0}", field.IsVisible); System.Console.WriteLine(" Order = {0}", field.Order); } } /// <summary> /// Prints the portfolio colors information. /// </summary> /// <param name="presentationColors">The presentation colors.</param> private static void PrintPortfolioColors( Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfPresentationColors presentationColors) { System.Console.WriteLine("Colors:"); System.Console.WriteLine(string.Format(" Background = {0}", presentationColors.Background)); System.Console.WriteLine(string.Format(" CardBackground = {0}", presentationColors.CardBackground)); System.Console.WriteLine(string.Format(" CardBorder = {0}", presentationColors.CardBorder)); System.Console.WriteLine(string.Format(" PrimaryText = {0}", presentationColors.PrimaryText)); System.Console.WriteLine(string.Format(" SecondaryText = {0}", presentationColors.SecondaryText)); }
System.Object
Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollection
Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Члены типа PdfAttachmentCollection
Пространство имен Vintasoft.Imaging.Pdf.Tree.FileAttachments
Extensions