Package com.itextpdf.kernel.pdf
Class PdfPagesTree
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfPagesTree
-
class PdfPagesTree extends java.lang.ObjectAlgorithm for constructionPdfPagestree
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static intDEFAULT_LEAF_SIZEprivate PdfDocumentdocumentprivate booleangeneratedprivate intleafSizeprivate static org.slf4j.LoggerLOGGERprivate ISimpleList<PdfIndirectReference>pageRefsprivate ISimpleList<PdfPage>pagesprivate java.util.List<PdfPages>parentsprivate PdfPagesroot
-
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 voidaddPage(int index, PdfPage pdfPage)InsertsPdfPageinto specific one-based position.voidaddPage(PdfPage pdfPage)Appends the specifiedPdfPageto the end of this tree.protected voidclearPageRefs()private voidcorrectPdfPagesFromProperty(int index, int correction)private intfindPageParent(int pageNum)protected PdfPagesfindPageParent(PdfPage pdfPage)protected PdfObjectgenerateTree()Generate PdfPages tree.intgetNumberOfPages()Gets total number of @see PdfPages.PdfPagegetPage(int pageNum)Returns thePdfPageat the specified position in this list.PdfPagegetPage(PdfDictionary pageDictionary)Returns thePdfPageby page's PdfDictionary.intgetPageNumber(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.intgetPageNumber(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 PdfPagesgetRoot()private booleaninternalRemovePage(int pageNum)private voidloadPage(int pageNum)private voidloadPage(int pageNum, java.util.Set<PdfIndirectReference> processedParents)Load page from pages tree node structure(package private) voidreleasePage(int pageNumber)PdfPageremovePage(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- aPdfCatalogwhich will be used to create the tree
-
-
Method Detail
-
getPage
public PdfPage getPage(int pageNum)
Returns thePdfPageat the specified position in this list.- Parameters:
pageNum- one-based index of the element to return- Returns:
- the
PdfPageat the specified position in this list
-
getPage
public PdfPage getPage(PdfDictionary pageDictionary)
Returns thePdfPageby page's PdfDictionary.- Parameters:
pageDictionary- page's PdfDictionary- Returns:
- the
PdfPageobject, 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 specifiedPdfPageto the end of this tree.- Parameters:
pdfPage- aPdfPageto be added
-
addPage
public void addPage(int index, PdfPage pdfPage)InsertsPdfPageinto specific one-based position.- Parameters:
index- one-base index of the pagepdfPage-PdfPageto 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)
-
-