Class StructureItems

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<StructureItem>, java.util.Collection<StructureItem>, java.util.List<StructureItem>, java.util.RandomAccess

    public class StructureItems
    extends java.util.ArrayList<StructureItem>
    Creates a list of StructureItem objects extracted from the Structure Tree of a PDF document.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static Logger LOGGER
      The Logger instance
      protected java.util.HashMap<java.lang.Integer,​PdfObject> parentTree
      The StructParents number tree values.
      private static long serialVersionUID
      Serial version UID
      protected PdfDictionary structTreeRoot
      The StructTreeRoot dictionary
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      StructureItems​(PdfReader reader)
      Creates a list of StructuredItem objects.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getNextMCID​(PdfNumber structParents)
      Finds the next available MCID, which is either the lowest empty ID in the existing range, or the first available higher number.
      int processMCID​(PdfNumber structParents, PdfIndirectReference ref)
      Creates a new MCID in the parent tree of the page and returns that new MCID so that it can be used in the content stream
      protected void processStructElemKids​(PdfDictionary structElem, PdfIndirectReference ref, PdfObject object)
      Processes the kids object of a StructElem dictionary.
      protected void processStructElems​(PdfDictionary structElem, PdfIndirectReference ref)
      Looks at a StructElem dictionary, and processes it.
      void removeFromParentTree​(PdfNumber structParent)
      Removes a StructParent from the parent tree.
      void writeParentTree​(PdfWriter writer)
      Writes the altered parent tree to a PdfWriter and updates the StructTreeRoot entry.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Field Detail

      • LOGGER

        protected static final Logger LOGGER
        The Logger instance
      • structTreeRoot

        protected PdfDictionary structTreeRoot
        The StructTreeRoot dictionary
      • parentTree

        protected java.util.HashMap<java.lang.Integer,​PdfObject> parentTree
        The StructParents number tree values.
      • serialVersionUID

        private static final long serialVersionUID
        Serial version UID
        See Also:
        Constant Field Values
    • Method Detail

      • processStructElemKids

        protected void processStructElemKids​(PdfDictionary structElem,
                                             PdfIndirectReference ref,
                                             PdfObject object)
                                      throws InvalidPdfException
        Processes the kids object of a StructElem dictionary. This kids object can be a number (MCID), another StructElem dictionary, an MCR dictionary, an OBJR dictionary, or an array of the above.
        Parameters:
        structElem - the StructElem dictionary
        ref - the reference to the StructElem dictionary
        object - the kids object
        Throws:
        InvalidPdfException
      • removeFromParentTree

        public void removeFromParentTree​(PdfNumber structParent)
        Removes a StructParent from the parent tree.
        Parameters:
        structParent - the number to remove
      • processMCID

        public int processMCID​(PdfNumber structParents,
                               PdfIndirectReference ref)
                        throws DocumentException
        Creates a new MCID in the parent tree of the page and returns that new MCID so that it can be used in the content stream
        Parameters:
        structParents - the StructParents entry in the page dictionary
        ref - the item for which we need a new MCID
        Returns:
        a new MCID
        Throws:
        DocumentException
      • getNextMCID

        public int getNextMCID​(PdfNumber structParents)
        Finds the next available MCID, which is either the lowest empty ID in the existing range, or the first available higher number.
        Parameters:
        structParents - the StructParents entry in the page dictionary
        Returns:
        the first available MCID
      • writeParentTree

        public void writeParentTree​(PdfWriter writer)
                             throws java.io.IOException
        Writes the altered parent tree to a PdfWriter and updates the StructTreeRoot entry.
        Parameters:
        writer - The writer to which the StructParents have to be written
        Throws:
        java.io.IOException