
[DefaultMember("Item")] public class PdfAttachmentCollectionSchema : Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionary<T>
[DefaultMember("Item")] public __gc class PdfAttachmentCollectionSchema : public Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionary<T*>*
[DefaultMember("Item")] public ref class PdfAttachmentCollectionSchema : public Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionary<T^>^
'Declaration <DefaultMemberAttribute("Item")> Public Class PdfAttachmentCollectionSchema Inherits Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionary(Of T)
Каждое имя ключа выбирается на усмотрение производителя. Ключевое имя каждого поля используется для идентификации соответствующих полей данных (DataFields) в спецификации файла.
Вот пример, показывающий, как создать схему коллекции вложений PDF:
''' <summary> ''' Creates new PDF document with portfolio and portfolio schema: ''' </summary> ''' <param name="outputPdfFilename">The output PDF filename.</param> Public Shared Sub TestPdfAttachmentCollectionSchema(outputPdfFilename As String) ' create PDF document (version 1.7) Using document As New Vintasoft.Imaging.Pdf.PdfDocument(outputPdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_17) ' add page to PDF document Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4) ' draw text on first page Using g As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = page.GetGraphics() Dim textBox As New Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.TextBoxFigure() textBox.Font = document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman) textBox.FontSize = 30 textBox.Location = New System.Drawing.PointF(0, 0) textBox.Size = page.MediaBox.Size textBox.TextAlignment = Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Top Or Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Left Or Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Right textBox.TextBrush = New Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Black) textBox.Text = "This document is Portfolio" & vbLf & "(Attachment Collection)" & vbLf & "To view Portfolio you should use PDF viewer compatible with PDF 1.7 ExtensionLevel 3." textBox.Draw(g) End Using ' create attachements document.CreateAttachments(True) ' set viewer settings document.Attachments.View = Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionViewMode.DetailsMode document.Attachments.SplitterBar = New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSplitterBar(document) document.Attachments.SplitterBar.Direction = Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSplitterBarDirection.None document.DocumentViewMode = Vintasoft.Imaging.Pdf.PdfDocumentViewMode.UseAttachments ' create folder and files Dim folder1 As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder = document.Attachments.RootFolder.AddFolder("Folder1") folder1.CreationDate = System.DateTime.Now Dim file1 As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification = AddFile(document.Attachments.RootFolder, "File1.txt", "Test File1") file1.CreationDate = System.DateTime.Now Dim file2 As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification = AddFile(document.Attachments.RootFolder, "File2.txt", "Test File2") file2.CreationDate = System.DateTime.Now ' create portfolio schema document.Attachments.Schema = New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchema(document) ' "File Name" column document.Attachments.Schema.Add("Filename", New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "File Name", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.Filename)) document.Attachments.Schema("Filename").Order = 0 ' "Uncompressed Size" column document.Attachments.Schema.Add("UncompressedSize", New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Uncompressed Size", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.UncompressedSize)) document.Attachments.Schema("UncompressedSize").Order = 1 ' "Creation Date" column document.Attachments.Schema.Add("CreationDate", New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Creation Date", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.CreationDate)) document.Attachments.Schema("CreationDate").Order = 2 ' "Description" column document.Attachments.Schema.Add("Description", New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Description", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.FileDescription)) document.Attachments.Schema("Description").Order = 3 ' set Description field as editable document.Attachments.Schema("Description").IsSupportsEditing = True ' "UserName" custom column (string data) Dim userNameFieldName As String = "adobe:UserName" document.Attachments.Schema.Add(userNameFieldName, New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "User Name", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.[String])) document.Attachments.Schema(userNameFieldName).Order = 4 ' disable editing of UserName field document.Attachments.Schema(userNameFieldName).IsSupportsEditing = False ' invisible schema field that is used for sorting attachment collection items Dim orderFieldName As String = "Order" document.Attachments.Schema.Add(orderFieldName, New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Order", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.Number)) document.Attachments.Schema(orderFieldName).Order = 5 document.Attachments.Schema(orderFieldName).IsVisible = False ' specify the sorting order: first sort by "Order" field, second sort by "Filename" field document.Attachments.Sort = New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSort(document) document.Attachments.Sort.FieldNames = New String() {orderFieldName, "Filename"} ' create data fields of Folder1 folder1.DataFields = New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentDataFieldCollection(document) folder1.DataFields.Add(userNameFieldName, "User of Folder1") folder1.DataFields.Add(orderFieldName, 0) ' create data fields of File1 file1.DataFields = New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentDataFieldCollection(document) file1.DataFields.Add(userNameFieldName, "User of File1") file1.DataFields.Add(orderFieldName, 1) ' create data fields of File2 file2.DataFields = New Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentDataFieldCollection(document) file2.DataFields.Add(userNameFieldName, "User of File2") file2.DataFields.Add(orderFieldName, 2) ' set descriptions folder1.Description = "Is empty folder." file1.Description = "Description of File1" file2.Description = "Description of File2" ' save changes in PDF document document.SaveChanges() End Using End Sub ''' <summary> ''' Adds the file to specified portfolio folder. ''' </summary> ''' <param name="folder">The portfolio folder.</param> ''' <param name="filename">The filename.</param> ''' <param name="fileContent">Content of the file.</param> ''' <returns>Embedded file specification that contains added file.</returns> Private Shared Function AddFile(folder As Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder, filename As String, fileContent As String) As Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification Using stream As New System.IO.MemoryStream() Using writer As System.IO.TextWriter = New System.IO.StreamWriter(stream) writer.Write(fileContent) writer.Flush() stream.Position = 0 Dim embeddedFile As New Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile(folder.Document, stream) Return folder.AddFile(embeddedFile, filename) End Using End Using End Function
/// <summary> /// Creates new PDF document with portfolio and portfolio schema: /// </summary> /// <param name="outputPdfFilename">The output PDF filename.</param> public static void TestPdfAttachmentCollectionSchema(string outputPdfFilename) { // create PDF document (version 1.7) using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(outputPdfFilename, Vintasoft.Imaging.Pdf.PdfFormat.Pdf_17)) { // add page to PDF document Vintasoft.Imaging.Pdf.Tree.PdfPage page = document.Pages.Add(Vintasoft.Imaging.PaperSizeKind.A4); // draw text on first page using (Vintasoft.Imaging.Pdf.Drawing.PdfGraphics g = page.GetGraphics()) { Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.TextBoxFigure textBox = new Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.TextBoxFigure(); textBox.Font = document.FontManager.GetStandardFont( Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman); textBox.FontSize = 30; textBox.Location = new System.Drawing.PointF(0, 0); textBox.Size = page.MediaBox.Size; textBox.TextAlignment = Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Top | Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Left | Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Right; textBox.TextBrush = new Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Black); textBox.Text = "This document is Portfolio\n(Attachment Collection)\nTo view Portfolio you should use PDF viewer compatible with PDF 1.7 ExtensionLevel 3."; textBox.Draw(g); } // create attachements document.CreateAttachments(true); // set viewer settings document.Attachments.View = Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionViewMode.DetailsMode; document.Attachments.SplitterBar = new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSplitterBar(document); document.Attachments.SplitterBar.Direction = Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSplitterBarDirection.None; document.DocumentViewMode = Vintasoft.Imaging.Pdf.PdfDocumentViewMode.UseAttachments; // create folder and files Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder folder1 = document.Attachments.RootFolder.AddFolder("Folder1"); folder1.CreationDate = System.DateTime.Now; Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification file1 = AddFile(document.Attachments.RootFolder, "File1.txt", "Test File1"); file1.CreationDate = System.DateTime.Now; Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification file2 = AddFile(document.Attachments.RootFolder, "File2.txt", "Test File2"); file2.CreationDate = System.DateTime.Now; // create portfolio schema document.Attachments.Schema = new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchema(document); // "File Name" column document.Attachments.Schema.Add("Filename", new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "File Name", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.Filename)); document.Attachments.Schema["Filename"].Order = 0; // "Uncompressed Size" column document.Attachments.Schema.Add("UncompressedSize", new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Uncompressed Size", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.UncompressedSize)); document.Attachments.Schema["UncompressedSize"].Order = 1; // "Creation Date" column document.Attachments.Schema.Add("CreationDate", new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Creation Date", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.CreationDate)); document.Attachments.Schema["CreationDate"].Order = 2; // "Description" column document.Attachments.Schema.Add("Description", new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Description", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.FileDescription)); document.Attachments.Schema["Description"].Order = 3; // set Description field as editable document.Attachments.Schema["Description"].IsSupportsEditing = true; // "UserName" custom column (string data) string userNameFieldName = "adobe:UserName"; document.Attachments.Schema.Add(userNameFieldName, new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "User Name", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.String)); document.Attachments.Schema[userNameFieldName].Order = 4; // disable editing of UserName field document.Attachments.Schema[userNameFieldName].IsSupportsEditing = false; // invisible schema field that is used for sorting attachment collection items string orderFieldName = "Order"; document.Attachments.Schema.Add(orderFieldName, new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField(document, "Order", Vintasoft.Imaging.Pdf.Tree.FileAttachments.AttachmentCollectionSchemaFieldDataType.Number)); document.Attachments.Schema[orderFieldName].Order = 5; document.Attachments.Schema[orderFieldName].IsVisible = false; // specify the sorting order: first sort by "Order" field, second sort by "Filename" field document.Attachments.Sort = new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSort(document); document.Attachments.Sort.FieldNames = new string[] { orderFieldName, "Filename" }; // create data fields of Folder1 folder1.DataFields = new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentDataFieldCollection(document); folder1.DataFields.Add(userNameFieldName, "User of Folder1"); folder1.DataFields.Add(orderFieldName, 0); // create data fields of File1 file1.DataFields = new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentDataFieldCollection(document); file1.DataFields.Add(userNameFieldName, "User of File1"); file1.DataFields.Add(orderFieldName, 1); // create data fields of File2 file2.DataFields = new Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentDataFieldCollection(document); file2.DataFields.Add(userNameFieldName, "User of File2"); file2.DataFields.Add(orderFieldName, 2); // set descriptions folder1.Description = "Is empty folder."; file1.Description = "Description of File1"; file2.Description = "Description of File2"; // save changes in PDF document document.SaveChanges(); } } /// <summary> /// Adds the file to specified portfolio folder. /// </summary> /// <param name="folder">The portfolio folder.</param> /// <param name="filename">The filename.</param> /// <param name="fileContent">Content of the file.</param> /// <returns>Embedded file specification that contains added file.</returns> private static Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFileSpecification AddFile( Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentFolder folder, string filename, string fileContent) { using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { using (System.IO.TextWriter writer = new System.IO.StreamWriter(stream)) { writer.Write(fileContent); writer.Flush(); stream.Position = 0; Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile embeddedFile = new Vintasoft.Imaging.Pdf.Tree.PdfEmbeddedFile(folder.Document, stream); return folder.AddFile(embeddedFile, filename); } } }
System.Object
Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionaryBase<Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField>
Vintasoft.Imaging.Pdf.Tree.PdfNamedDictionary<Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchemaField>
Vintasoft.Imaging.Pdf.Tree.FileAttachments.PdfAttachmentCollectionSchema
Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Члены типа PdfAttachmentCollectionSchema
Пространство имен Vintasoft.Imaging.Pdf.Tree.FileAttachments
PdfAttachmentCollection
Schema
AttachmentCollectionViewMode
PdfAttachmentDataFieldCollection
DataFields
DataFields