Package com.itextpdf.text.pdf.mc
Class StructureItems
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<StructureItem>
-
- com.itextpdf.text.pdf.mc.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 instanceprotected java.util.HashMap<java.lang.Integer,PdfObject>
parentTree
The StructParents number tree values.private static long
serialVersionUID
Serial version UIDprotected PdfDictionary
structTreeRoot
The StructTreeRoot dictionary
-
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 streamprotected 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
-
-
-
-
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
-
-
Constructor Detail
-
StructureItems
public StructureItems(PdfReader reader) throws DocumentException, InvalidPdfException
Creates a list of StructuredItem objects.- Parameters:
reader
- the reader holding the PDF to examine- Throws:
DocumentException
InvalidPdfException
-
-
Method Detail
-
processStructElems
protected void processStructElems(PdfDictionary structElem, PdfIndirectReference ref) throws InvalidPdfException
Looks at a StructElem dictionary, and processes it.- Parameters:
structElem
- the StructElem dictionary that needs to be examinedref
- the reference to the StructElem dictionary- Throws:
DocumentException
InvalidPdfException
-
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 dictionaryref
- the reference to the StructElem dictionaryobject
- 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 dictionaryref
- 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
-
-