Class DocumentPart

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class DocumentPart
    extends java.lang.Object
    A DocumentPart represents a contiguous list of pages from a PDF. It's primarily used when combining multiple files into one for printing, or for other special purposes, such as PDF/mail. It is a new concept in PDF 2.0
    Since:
    2.28.3
    See Also:
    PDFPage.getDocumentPart(), PDF.getDocumentPart()
    • Constructor Summary

      Constructors 
      Constructor Description
      DocumentPart()
      Create a new DocumentPart
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Object clone()  
      java.util.Collection<EmbeddedFile> getAssociatedFiles()
      Return the list of embedded files assocatiated with this object.
      java.util.List<DocumentPart> getDocumentParts()
      Return the list of child DocumentParts that belong to this DocumentPart.
      java.util.List<PDFPage> getPages()
      Return the list of pages that are included in this Document Part.
      DocumentPart getParent()
      Return the parent DocumentPart if this object has one, or null if it is the root or is not yet connected to a tree
      java.util.Map<java.lang.String,​java.lang.Object> getProperties()
      Return the properties (called the "Document Part Metadata Dictionary" in the spec) as a Map where the values are String, Number, Calendar, Boolean, or a List or Map where the values also meet that criteria.
      XMP getXMP()
      Return an XMP Metadata object representing any XML metadata associated with this object
      boolean isEmpty()
      Return true if this DocumentPart has no pages and no child DocumentParts
      boolean isLeaf()
      Return true if this DocumentPart does not contain child DocumentParts
      void putLiteral​(java.lang.String key, java.lang.String tokens)
      Put a literal token sequnce.
      void setProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties)
      Set the properties (called the "Document Part Metadata Dictionary" in the spec).
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DocumentPart

        public DocumentPart()
        Create a new DocumentPart
    • Method Detail

      • getParent

        public DocumentPart getParent()
        Return the parent DocumentPart if this object has one, or null if it is the root or is not yet connected to a tree
        Returns:
        the parent DocumentPart
      • getPages

        public java.util.List<PDFPage> getPages()
        Return the list of pages that are included in this Document Part. The list is contiguous - it matches a sublist of PDF.getPages(). When adding or removing items to it, the list must be contiguous at all times. A DocumentPart cannot have both Pages and DocumentParts at the same time. Pages cannot be added to a DocumentPart until it's been added to a PDF
        Returns:
        an editable list of pages
      • getDocumentParts

        public java.util.List<DocumentPart> getDocumentParts()
        Return the list of child DocumentParts that belong to this DocumentPart. The list is modifiable, but DocumentParts cannot belong to more than one parent at a time. A DocumentPart cannot have both Pages and DocumentParts at the same time.
      • getAssociatedFiles

        public java.util.Collection<EmbeddedFile> getAssociatedFiles()
        Return the list of embedded files assocatiated with this object. The list is live and can be edited.
      • getXMP

        public XMP getXMP()
        Return an XMP Metadata object representing any XML metadata associated with this object
        Returns:
        the XMP, which may be empty or invalid but will never be null
      • isEmpty

        public boolean isEmpty()
        Return true if this DocumentPart has no pages and no child DocumentParts
      • isLeaf

        public boolean isLeaf()
        Return true if this DocumentPart does not contain child DocumentParts
      • getProperties

        public java.util.Map<java.lang.String,​java.lang.Object> getProperties()
        Return the properties (called the "Document Part Metadata Dictionary" in the spec) as a Map where the values are String, Number, Calendar, Boolean, or a List or Map where the values also meet that criteria. The returned Map is a copy, so any changes to it will not be applied unless the Map is passed back into setProperties(java.util.Map<java.lang.String, java.lang.Object>)
        Returns:
        the Document Part Metadata properties - if none are specified, will return an empty Map.
      • setProperties

        public void setProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties)
        Set the properties (called the "Document Part Metadata Dictionary" in the spec). The supplied Map should contain only the values described in getProperties(), anything else will be ignored. A value of null will remove the properties
        Parameters:
        properties - the Document Part Metadata properties
      • toString

        public java.lang.String toString()
      • putLiteral

        public void putLiteral​(java.lang.String key,
                               java.lang.String tokens)
        Put a literal token sequnce. For debugging
        Parameters:
        key - the key
        tokens - the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
      • clone

        protected java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object