Package com.itextpdf.kernel.pdf
Class PdfPagesTree
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfPagesTree
-
class PdfPagesTree extends java.lang.Object
Algorithm for constructionPdfPages
tree
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
DEFAULT_LEAF_SIZE
private PdfDocument
document
private boolean
generated
private int
leafSize
private static org.slf4j.Logger
LOGGER
private ISimpleList<PdfIndirectReference>
pageRefs
private ISimpleList<PdfPage>
pages
private java.util.List<PdfPages>
parents
private PdfPages
root
-
Constructor Summary
Constructors Constructor Description PdfPagesTree(PdfCatalog pdfCatalog)
Creates a PdfPages tree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPage(int index, PdfPage pdfPage)
InsertsPdfPage
into specific one-based position.void
addPage(PdfPage pdfPage)
Appends the specifiedPdfPage
to the end of this tree.protected void
clearPageRefs()
private void
correctPdfPagesFromProperty(int index, int correction)
private int
findPageParent(int pageNum)
protected PdfPages
findPageParent(PdfPage pdfPage)
protected PdfObject
generateTree()
Generate PdfPages tree.int
getNumberOfPages()
Gets total number of @see PdfPages.PdfPage
getPage(int pageNum)
Returns thePdfPage
at the specified position in this list.PdfPage
getPage(PdfDictionary pageDictionary)
Returns thePdfPage
by page's PdfDictionary.int
getPageNumber(PdfDictionary pageDictionary)
Returns the index of the first occurrence of the page in this tree specified by it's PdfDictionary, or 0 if this tree does not contain the page.int
getPageNumber(PdfPage page)
Returns the index of the first occurrence of the specified page in this tree, or 0 if this tree does not contain the page.protected java.util.List<PdfPages>
getParents()
protected PdfPages
getRoot()
private boolean
internalRemovePage(int pageNum)
private void
loadPage(int pageNum)
private void
loadPage(int pageNum, java.util.Set<PdfIndirectReference> processedParents)
Load page from pages tree node structure(package private) void
releasePage(int pageNumber)
PdfPage
removePage(int pageNum)
Removes the page at the specified position in this tree.
-
-
-
Field Detail
-
DEFAULT_LEAF_SIZE
static final int DEFAULT_LEAF_SIZE
- See Also:
- Constant Field Values
-
leafSize
private final int leafSize
- See Also:
- Constant Field Values
-
pageRefs
private ISimpleList<PdfIndirectReference> pageRefs
-
parents
private java.util.List<PdfPages> parents
-
pages
private ISimpleList<PdfPage> pages
-
document
private final PdfDocument document
-
generated
private boolean generated
-
root
private PdfPages root
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Constructor Detail
-
PdfPagesTree
public PdfPagesTree(PdfCatalog pdfCatalog)
Creates a PdfPages tree.- Parameters:
pdfCatalog
- aPdfCatalog
which will be used to create the tree
-
-
Method Detail
-
getPage
public PdfPage getPage(int pageNum)
Returns thePdfPage
at the specified position in this list.- Parameters:
pageNum
- one-based index of the element to return- Returns:
- the
PdfPage
at the specified position in this list
-
getPage
public PdfPage getPage(PdfDictionary pageDictionary)
Returns thePdfPage
by page's PdfDictionary.- Parameters:
pageDictionary
- page's PdfDictionary- Returns:
- the
PdfPage
object, that wrapspageDictionary
.
-
getNumberOfPages
public int getNumberOfPages()
Gets total number of @see PdfPages.- Returns:
- total number of pages
-
getPageNumber
public int getPageNumber(PdfPage page)
Returns the index of the first occurrence of the specified page in this tree, or 0 if this tree does not contain the page.
-
getPageNumber
public int getPageNumber(PdfDictionary pageDictionary)
Returns the index of the first occurrence of the page in this tree specified by it's PdfDictionary, or 0 if this tree does not contain the page.
-
addPage
public void addPage(PdfPage pdfPage)
Appends the specifiedPdfPage
to the end of this tree.- Parameters:
pdfPage
- aPdfPage
to be added
-
addPage
public void addPage(int index, PdfPage pdfPage)
InsertsPdfPage
into specific one-based position.- Parameters:
index
- one-base index of the pagepdfPage
-PdfPage
to insert.
-
removePage
public PdfPage removePage(int pageNum)
Removes the page at the specified position in this tree. Shifts any subsequent elements to the left (subtracts one from their indices).- Parameters:
pageNum
- the one-based index of the PdfPage to be removed- Returns:
- the page that was removed from the list
-
releasePage
void releasePage(int pageNumber)
-
generateTree
protected PdfObject generateTree()
Generate PdfPages tree.- Returns:
- root
PdfPages
- Throws:
PdfException
- in case empty document
-
clearPageRefs
protected void clearPageRefs()
-
getParents
protected java.util.List<PdfPages> getParents()
-
getRoot
protected PdfPages getRoot()
-
loadPage
private void loadPage(int pageNum)
-
loadPage
private void loadPage(int pageNum, java.util.Set<PdfIndirectReference> processedParents)
Load page from pages tree node structure- Parameters:
pageNum
- page number to loadprocessedParents
- set with already processed parents object reference numbers if this method was called recursively to avoid infinite recursion.
-
internalRemovePage
private boolean internalRemovePage(int pageNum)
-
findPageParent
private int findPageParent(int pageNum)
-
correctPdfPagesFromProperty
private void correctPdfPagesFromProperty(int index, int correction)
-
-