Class StructureTreeCopier

java.lang.Object
com.itextpdf.kernel.pdf.tagging.StructureTreeCopier

class StructureTreeCopier extends Object
Internal helper class which is used to copy, clone or move tag structure across documents.
  • Field Details

    • ignoreKeysForCopy

      private static List<PdfName> ignoreKeysForCopy
    • ignoreKeysForClone

      private static List<PdfName> ignoreKeysForClone
  • Constructor Details

    • StructureTreeCopier

      StructureTreeCopier()
  • Method Details

    • copyTo

      public static void copyTo(PdfDocument destDocument, Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument)
      Copies structure to a destDocument.

      NOTE: Works only for PdfStructTreeRoot that is read from the document opened in reading mode, otherwise an exception is thrown.
      Parameters:
      destDocument - document to copy structure to. Shall not be current document.
      page2page - association between original page and copied page.
    • copyTo

      public static void copyTo(PdfDocument destDocument, int insertBeforePage, Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument)
      Copies structure to a destDocument and insert it in a specified position in the document.

      NOTE: Works only for PdfStructTreeRoot that is read from the document opened in reading mode, otherwise an exception is thrown.
      Also, to insert a tagged page into existing tag structure, existing tag structure shouldn't be flushed, otherwise an exception may be raised.
      Parameters:
      destDocument - document to copy structure to.
      insertBeforePage - indicates where the structure to be inserted.
      page2page - association between original page and copied page.
    • move

      public static void move(PdfDocument document, PdfPage from, int insertBefore)
      Move tag structure of page to other place in the same document
      Parameters:
      document - document in which modifications will take place (should be opened in read-write mode)
      from - page, which tag structure will be moved
      insertBefore - indicates before what page number structure will be inserted to
    • separateStructure

      private static int separateStructure(PdfDocument document, int beforePage)
      Returns:
      structure tree index of first separated (cloned) top
    • separateStructure

      private static int separateStructure(PdfDocument document, int startPage, int beforePage, int startPageStructTopIndex)
    • copyTo

      private static void copyTo(PdfDocument destDocument, int insertBeforePage, Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument)
    • copyTo

      private static void copyTo(PdfDocument destDocument, Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument)
      Copies structure to a destDocument.
      Parameters:
      destDocument - document to cpt structure to.
      page2page - association between original page and copied page.
      copyFromDestDocument - indicates if page2page keys and values represent pages from destDocument.
    • copyTo

      private static void copyTo(PdfDocument destDocument, Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument, int insertIndex)
    • copyStructure

      private static StructureTreeCopier.CopyStructureResult copyStructure(PdfDocument destDocument, Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument)
    • copyObject

      private static PdfDictionary copyObject(PdfDictionary source, PdfDictionary destPage, boolean parentChangePg, StructureTreeCopier.StructElemCopyingParams copyingParams)
    • copyObjectKid

      private static PdfObject copyObjectKid(PdfObject kid, PdfDictionary copiedParent, PdfDictionary destPage, boolean parentChangePg, StructureTreeCopier.StructElemCopyingParams copyingParams, PdfDictionary lastCopiedTrPage)
    • shouldTableElementBeCopied

      static boolean shouldTableElementBeCopied(PdfDictionary obj, PdfDictionary parent)
    • copyNamespaceDict

      private static PdfDictionary copyNamespaceDict(PdfDictionary srcNsDict, StructureTreeCopier.StructElemCopyingParams copyingParams)
    • separateKids

      private static void separateKids(PdfDictionary structElem, Set<PdfObject> firstPartElems, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document)
    • cloneParents

      private static void cloneParents(PdfDictionary structElem, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document)
    • addAllParentsToSet

      private static PdfDictionary addAllParentsToSet(PdfMcr mcr, Set<PdfObject> set)
      Returns:
      the topmost parent added to set. If encountered flushed element - stops and returns this flushed element.
    • getTopmostParent

      private static PdfDictionary getTopmostParent(PdfMcr mcr)
      Gets the topmost non-root structure element parent. May be flushed.
      Parameters:
      mcr - starting element
      Returns:
      topmost non-root structure element parent, or null if it doesn't have any
    • retrieveParents

      private static List<PdfDictionary> retrieveParents(PdfMcr mcr, boolean all)