Class PdfAttachmentCollection
Represents a collection of the attachment objects.
Implements
System.Collections.IEnumerable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfAttachmentCollection : PdfCollection, IEnumerable, IPdfWrapper
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create an attachment.
PdfAttachment attachment = new PdfAttachment("Input.txt");
attachment.Description = "Input.txt";
attachment.MimeType = "application/txt";
//Add the attachment to the document.
document.Attachments.Add(attachment);
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create an attachment.
Dim attachment As New PdfAttachment("Input.txt")
attachment.Description = "Input.txt"
attachment.MimeType = "application/txt"
'Add the attachment to the document.
document.Attachments.Add(attachment)
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
Constructors
PdfAttachmentCollection()
Initializes a new instance of the PdfAttachmentCollection class.
Declaration
public PdfAttachmentCollection()
Properties
Item[Int32]
Declaration
public PdfAttachment this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
PdfAttachment |
Methods
Add(PdfAttachment)
Declaration
public int Add(PdfAttachment attachment)
Parameters
Type | Name | Description |
---|---|---|
PdfAttachment | attachment |
Returns
Type | Description |
---|---|
System.Int32 |
Clear()
Remove all the attachments from the collection.
Declaration
public void Clear()
Examples
//Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Get the attachments
PdfAttachmentCollection attachments = loadedDocument.Attachments;
//Remove all the bookmarks form the collection
attachments.Clear();
//Save and close the PDF document
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Get the attachments
Dim attachments As PdfAttachmentCollection = loadedDocument.Attachments
'Remove all the bookmarks form the collection
attachments.Clear()
'Save and close the document
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
Contains(PdfAttachment)
Determines whether the attachment collection contains the specified attachment.
Declaration
public bool Contains(PdfAttachment attachment)
Parameters
Type | Name | Description |
---|---|---|
PdfAttachment | attachment | The attachment to be searched. |
Returns
Type | Description |
---|---|
System.Boolean | if it contains the specified attachment, set to |
Examples
//Create a new PDF document
PdfDocument document = new PdfDocument();
//Create an attachment
PdfAttachment attachment = new PdfAttachment("Input.txt");
attachment.Description = "Input.txt";
attachment.MimeType = "application/txt";
//Add the attachment to the document
document.Attachments.Add(attachment);
//check the collection contains the specified attachment.
bool isAttachmentContained = document.Attachments.Contains(attachment);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new PDF document
Dim document As New PdfDocument()
'Create an attachment
Dim attachment As New PdfAttachment("Input.txt")
attachment.Description = "Input.txt"
attachment.MimeType = "application/txt"
'Add the attachment to the document
document.Attachments.Add(attachment)
'check the collection contains the specified attachment.
Dim isAttachmentContained As Boolean = document.Attachments.Contains(attachment)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
IndexOf(PdfAttachment)
search and find the index of the attachment.
Declaration
public int IndexOf(PdfAttachment attachment)
Parameters
Type | Name | Description |
---|---|---|
PdfAttachment | attachment | The attachment to find the position. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the specified attachment. |
Examples
//Create a new PDF document
PdfDocument document = new PdfDocument();
//Create an attachment
PdfAttachment attachment = new PdfAttachment("Input.txt");
attachment.Description = "Input.txt";
attachment.MimeType = "application/txt";
//Add the attachment to the document
document.Attachments.Add(attachment);
//Get the index of attachment
int index = document.Attachments.IndexOf(attachment);
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new PDF document
Dim document As New PdfDocument()
'Create an attachment
Dim attachment As New PdfAttachment("Input.txt")
attachment.Description = "Input.txt"
attachment.MimeType = "application/txt"
'Add the attachment to the document
document.Attachments.Add(attachment)
'Get the index of attachment
Dim index As Integer = document.Attachments.IndexOf(attachment)
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Insert(Int32, PdfAttachment)
Inserts the attachment at specified index.
Declaration
public void Insert(int index, PdfAttachment attachment)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index at which attachment to be inserted. |
PdfAttachment | attachment | The attachment to be inserted. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create an attachment.
PdfAttachment attachment = new PdfAttachment("Input.txt");
attachment.Description = "Input.txt";
attachment.MimeType = "application/txt";
//insert the attachment at specified index.
document.Attachments.Insert(0, attachment);
//Save and close the PDF document.
document.Save("Output.pdf");
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create an attachment.
Dim attachment As New PdfAttachment("Input.txt")
attachment.Description = "Input.txt"
attachment.MimeType = "application/txt"
'insert the attachment at specified index.
document.Attachments.Insert(0, attachment)
'Save and close the PDF document.
document.Save("Output.pdf")
document.Close(True)
See Also
Remove(PdfAttachment)
Removes the specified attachment from the collection.
Declaration
public void Remove(PdfAttachment attachment)
Parameters
Type | Name | Description |
---|---|---|
PdfAttachment | attachment | The attachment to be removed. |
Examples
//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Load an attachment collection.
PdfAttachmentCollection attachments = loadedDocument.Attachments;
//Get the attachment at the specified index.
PdfAttachment attachment = loadedDocument.Attachments[0];
//Remove attachment by attachment name.
attachments.Remove(attachment);
//Save and close the document.
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document.
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Load an attachment collection.
Dim attachments As PdfAttachmentCollection = loadedDocument.Attachments
'Get the attachment at the specified index.
attachment As PdfAttachment = loadedDocument.Attachments(0)
'Remove attachment by attachment name.
attachments.Remove(attachment)
'Save and close the document.
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
RemoveAt(Int32)
Removes attachment at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index at which the attachment to be removed. |
Examples
//Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("Input.pdf");
//Load an attachment collection
PdfAttachmentCollection attachments = loadedDocument.Attachments;
//Remove attachment by index
attachments.RemoveAt(0);
//Save and close the document
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);
'Load the PDF document
Dim loadedDocument As New PdfLoadedDocument("Input.pdf")
'Load an attachment collection
Dim attachments As PdfAttachmentCollection = loadedDocument.Attachments
'Remove attachment by index
attachments.RemoveAt(0)
'Save and close the document
loadedDocument.Save("Output.pdf")
loadedDocument.Close(True)
See Also
Implements
System.Collections.IEnumerable