Class StructureTreeCopier


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

      • ignoreKeysForCopy

        private static java.util.List<PdfName> ignoreKeysForCopy
      • ignoreKeysForClone

        private static java.util.List<PdfName> ignoreKeysForClone
    • Constructor Detail

      • StructureTreeCopier

        StructureTreeCopier()
    • Method Detail

      • copyTo

        public static void copyTo​(PdfDocument destDocument,
                                  java.util.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,
                                  java.util.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,
                                   java.util.Map<PdfPage,​PdfPage> page2page,
                                   PdfDocument callingDocument,
                                   boolean copyFromDestDocument)
      • copyTo

        private static void copyTo​(PdfDocument destDocument,
                                   java.util.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,
                                   java.util.Map<PdfPage,​PdfPage> page2page,
                                   PdfDocument callingDocument,
                                   boolean copyFromDestDocument,
                                   int insertIndex)
      • addAllParentsToSet

        private static PdfDictionary addAllParentsToSet​(PdfMcr mcr,
                                                        java.util.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 java.util.List<PdfDictionary> retrieveParents​(PdfMcr mcr,
                                                                     boolean all)