public class DocumentAttachments
extends com.aspose.ms.System.Collections.CollectionBase
Represents a set of document level attachment Paragraph
in a Pdf document. Attachment can be file attachment,
stream attachment or note annotation.
[C#] Pdf pdf1 = new Pdf(); Section sec1 = pdf1.Sections.Add(); FileStream fstream; fstream = new FileStream("c:/word.doc", FileMode.Open); DocumentAttachment DocStreamAttachment = new DocumentAttachment(); pdf1.DocumentAttachments.Add(DocStreamAttachment); DocStreamAttachment.DocumentAttachmentStream = fstream; DocStreamAttachment.DocumentAttachmentCotentType = "doc"; DocumentAttachment DocFileAttachment = new DocumentAttachment(); pdf1.DocumentAttachments.Add(DocFileAttachment); DocFileAttachment.DocumentAttachmentFile = @"c:/image.jpg"; DocFileAttachment.DocumentAttachmentCotentType = "jpeg"; Attachment PageFileAttachment = new Attachment(); sec1.Paragraphs.Add(PageFileAttachment); PageFileAttachment.AttachmentType = AttachmentType.File; PageFileAttachment.AttachedFileName = "c:/text.txt"; PageFileAttachment.AttachedFileType = "txt"; PageFileAttachment.FileIconType = FileIconType.Graph; PageFileAttachment.IconColor = new Aspose.Pdf.Generator.Color("Brown"); fstream = new FileStream("c:/readme.txt", FileMode.Open); Attachment PageStreamAttachment = new Attachment(); sec1.Paragraphs.Add(PageStreamAttachment); PageStreamAttachment.AttachedStream = fstream; PageStreamAttachment.AttachedFileType = "txt"; PageStreamAttachment.AttachmentType = AttachmentType.File; PageStreamAttachment.FileIconType = FileIconType.PaperClip; Attachment PageNoteAttachment = new Attachment(); sec1.Paragraphs.Add(PageNoteAttachment); PageNoteAttachment.AttachmentType = AttachmentType.Note; PageNoteAttachment.NoteContent = "This is a note."; PageNoteAttachment.IsNoteOpen = true; pdf1.Save("test.pdf"); [Visual Basic] Dim pdf1 As Pdf = New Pdf() Dim sec1 As Section = pdf1.Sections.Add() Dim fstream As FileStream = new FileStream("c:/word.doc", FileMode.Open) Dim DocStreamAttachment As DocumentAttachment = New DocumentAttachment() pdf1.DocumentAttachments.Add(DocStreamAttachment) DocStreamAttachment.DocumentAttachmentStream = fstream DocStreamAttachment.DocumentAttachmentCotentType = "doc" Dim DocFileAttachment As DocumentAttachment = New DocumentAttachment() pdf1.DocumentAttachments.Add(DocFileAttachment) DocFileAttachment.DocumentAttachmentFile = @"c:/image.jpg" DocFileAttachment.DocumentAttachmentCotentType = "jpeg" Dim PageFileAttachment As Attachment = New Attachment() sec1.Paragraphs.Add(PageFileAttachment) PageFileAttachment.AttachmentType = AttachmentType.File PageFileAttachment.AttachedFileName = "c:/text.txt" PageFileAttachment.AttachedFileType = "txt" PageFileAttachment.FileIconType = FileIconType.Graph PageFileAttachment.IconColor = new Aspose.Pdf.Generator.Color("Brown") fstream = new FileStream("c:/readme.txt", FileMode.Open) Dim PageStreamAttachment As Attachment = New Attachment() sec1.Paragraphs.Add(PageStreamAttachment) PageStreamAttachment.AttachedStream = fstream PageStreamAttachment.AttachedFileType = "txt" PageStreamAttachment.AttachmentType = AttachmentType.File PageStreamAttachment.FileIconType = FileIconType.PaperClip Dim PageNoteAttachment As Attachment = New Attachment() sec1.Paragraphs.Add(PageNoteAttachment) PageNoteAttachment.AttachmentType = AttachmentType.Note PageNoteAttachment.NoteContent = "This is a note." PageNoteAttachment.IsNoteOpen = true pdf1.Save("test.pdf") [XML] <?xml version="1.0" encoding="utf-8" ?> <Pdf xmlns="Aspose.Pdf"> <DocumentAttachment DocumentAttachmentFileName="c:/word.doc" DocumentAttachmentFileType="doc"> </DocumentAttachment> <DocumentAttachment DocumentAttachmentFileName="c:/image.jpg" DocumentAttachmentFileType="jpeg"> </DocumentAttachment> <Section> <Attachment AttachmentType="File" AttachedFileName="c:/text.txt" AttachedFileType="txt" FileIconType="Graph" IconColor="Brown"> </Attachment> <Attachment AttachmentType="File" AttachedFileName="c:/readme.txt" AttachedFileType="txt" FileIconType="PaperClip"> </Attachment> <Attachment AttachmentType="Note" IsNoteOpen="true" NoteContent="This is a note."> </Attachment> </Section> </Pdf>
Constructor and Description |
---|
DocumentAttachments() |
Modifier and Type | Method and Description |
---|---|
void |
add(DocumentAttachment docattachment)
Adds a new
DocumentAttachment object into the collection. |
DocumentAttachment |
get_Item(int index)
Gets or sets a
DocumentAttachment object from the collection according to DocumentAttachment index. |
void |
insert(DocumentAttachment attachmentToInsertAfter,
DocumentAttachment newAttachment)
Inserts a new
DocumentAttachment object into the collection after specified DocumentAttachment object. |
void |
insert(int index,
DocumentAttachment attachment)
Inserts a new
DocumentAttachment object into the collection after specified DocumentAttachment object. |
void |
remove(DocumentAttachment attachmentToRemove)
Removes a
DocumentAttachment object from the collection. |
void |
remove(int index)
Removes a
DocumentAttachment object from the collection. |
void |
set_Item(int index,
DocumentAttachment value) |
public void add(DocumentAttachment docattachment)
Adds a new DocumentAttachment
object into the collection.
docattachment
- The DocumentAttachment
object to be added.public void insert(DocumentAttachment attachmentToInsertAfter, DocumentAttachment newAttachment)
Inserts a new DocumentAttachment
object into the collection after specified DocumentAttachment
object.
attachmentToInsertAfter
- The DocumentAttachment
object to insert after.
If this object is null, the new object will be inserted as the first member.newAttachment
- The DocumentAttachment
object to be inserted.public void insert(int index, DocumentAttachment attachment)
Inserts a new DocumentAttachment
object into the collection after specified DocumentAttachment
object.
index
- The zero-based index at which DocumentAttachment
object should be inserted.attachment
- The DocumentAttachment
object to be inserted.public void remove(DocumentAttachment attachmentToRemove)
Removes a DocumentAttachment
object from the collection.
attachmentToRemove
- The DocumentAttachment
object to be romoved.public void remove(int index)
Removes a DocumentAttachment
object from the collection.
index
- The index of the DocumentAttachment
object to be romoved.public DocumentAttachment get_Item(int index)
Gets or sets a DocumentAttachment
object from the collection according to DocumentAttachment index.
get_Item
in interface com.aspose.ms.System.Collections.IList
get_Item
in class com.aspose.ms.System.Collections.CollectionBase
public void set_Item(int index, DocumentAttachment value)
Copyright © 2016 Aspose. All Rights Reserved.