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.
[Java] Pdf pdf1 = new Pdf(); Section sec1 = pdf1.getSections().add(); InputStream fstream = new FileInputStream("c:/word.doc"); DocumentAttachment DocStreamAttachment = new DocumentAttachment(); pdf1.getDocumentAttachments().add(DocStreamAttachment); DocStreamAttachment.setDocumentAttachmentStream ( fstream); DocStreamAttachment.setDocumentAttachmentCotentType ( "doc"); DocumentAttachment DocFileAttachment = new DocumentAttachment(); pdf1.getDocumentAttachments.add(DocFileAttachment); DocFileAttachment.setDocumentAttachmentFile ( "c:/image.jpg"); DocFileAttachment.setDocumentAttachmentCotentType ( "jpeg"0; Attachment PageFileAttachment = new Attachment(); sec1.getParagraphs.add(PageFileAttachment); PageFileAttachment.setAttachmentType ( AttachmentType.File); PageFileAttachment.setAttachedFileName ( "c:/text.txt"); PageFileAttachment.setAttachedFileType ( "txt"); PageFileAttachment.setFileIconType ( FileIconType.Graph); PageFileAttachment.setIconColor ( new aspose.pdf.generator.Color("Brown")); fstream = new FileInputStream("c:/readme.txt"); Attachment PageStreamAttachment = new Attachment(); sec1.getParagraphs().add(PageStreamAttachment); PageStreamAttachment.setAttachedStream ( fstream); PageStreamAttachment.setAttachedFileType ( "txt"); PageStreamAttachment.setAttachmentType ( AttachmentType.File); PageStreamAttachment.setFileIconType ( FileIconType.PaperClip); Attachment PageNoteAttachment = new Attachment(); sec1.getParagraphs().add(PageNoteAttachment); PageNoteAttachment.setAttachmentType ( AttachmentType.Note); PageNoteAttachment.setNoteContent ( "This is a note."); PageNoteAttachment.setIsNoteOpen ( 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 removedAttach)
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 removedAttach)
Removes a DocumentAttachment
object from the collection.
removedAttach
- 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 © 2014 Aspose. All Rights Reserved.