aspose.pdf
Class DocumentAttachments

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by aspose.pdf.DocumentAttachments
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class DocumentAttachments
extends java.util.ArrayList

Represents a set of document level attachment Paragraph in a Pdf document. Attachment can be file attachment, stream attachment or note annotation.

Typical usages are the following:

[Java] [Java] Pdf pdf1 = new Pdf(); Section sec1 = pdf1.getSections().add(); TextFileStream fstream; fstream = new TextFileStream("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"); 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.Color("Brown")); fstream = new TextFileStream("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>

See Also:
Serialized Form

Constructor Summary
DocumentAttachments()
          Constructor - initializes a new instance of the DocumentAttachments class.
 
Method Summary
 void add(DocumentAttachment docattachment)
          Adds a new DocumentAttachment object into the collection.
 DocumentAttachment getDocumentAttachment(int index)
          Gets 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 setDocumentAttachment(int index, DocumentAttachment value)
          Sets a DocumentAttachment object from the collection according to DocumentAttachment index.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

DocumentAttachments

public DocumentAttachments()
Constructor - initializes a new instance of the DocumentAttachments class.

Method Detail

add

public void add(DocumentAttachment docattachment)
Adds a new DocumentAttachment object into the collection.

Parameters:
docattachment - DocumentAttachment object.

insert

public void insert(DocumentAttachment attachmentToInsertAfter,
                   DocumentAttachment newAttachment)
Inserts a new DocumentAttachment object into the collection after specified DocumentAttachment object.

Parameters:
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.

Insert

public void Insert(int index,
                   DocumentAttachment attachment)
Inserts a new DocumentAttachment object into the collection after specified DocumentAttachment object.

Parameters:
index - The zero-based index at which DocumentAttachment object should be inserted.
attachment - The DocumentAttachment object to be inserted.

remove

public void remove(DocumentAttachment attachmentToRemove)
Removes a DocumentAttachment object from the collection.

Parameters:
attachmentToRemove - The DocumentAttachment object to be removed.

getDocumentAttachment

public DocumentAttachment getDocumentAttachment(int index)
Gets a DocumentAttachment object from the collection according to DocumentAttachment index.


setDocumentAttachment

public void setDocumentAttachment(int index,
                                  DocumentAttachment value)
Sets a DocumentAttachment object from the collection according to DocumentAttachment index.

Parameters:
index - Position where the DocumentAttachment object should be set in.
value - DocumentAttachment object should be set.