Class PdfPagesTree

java.lang.Object
com.itextpdf.kernel.pdf.PdfPagesTree

class PdfPagesTree extends Object
Algorithm for construction PdfPages tree
  • Field Details

  • Constructor Details

    • PdfPagesTree

      public PdfPagesTree(PdfCatalog pdfCatalog)
      Creates a PdfPages tree.
      Parameters:
      pdfCatalog - a PdfCatalog which will be used to create the tree
  • Method Details

    • getPage

      public PdfPage getPage(int pageNum)
      Returns the PdfPage 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 the PdfPage by page's PdfDictionary.
      Parameters:
      pageDictionary - page's PdfDictionary
      Returns:
      the PdfPage object, that wraps pageDictionary.
    • 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 specified PdfPage to the end of this tree.
      Parameters:
      pdfPage - a PdfPage to be added
    • addPage

      public void addPage(int index, PdfPage pdfPage)
      Inserts PdfPage into specific one-based position.
      Parameters:
      index - one-base index of the page
      pdfPage - 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 List<PdfPages> getParents()
    • getRoot

      protected PdfPages getRoot()
    • findPageParent

      protected PdfPages findPageParent(PdfPage pdfPage)
    • loadPage

      private void loadPage(int pageNum)
    • loadPage

      private void loadPage(int pageNum, Set<PdfIndirectReference> processedParents)
      Load page from pages tree node structure
      Parameters:
      pageNum - page number to load
      processedParents - 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)