Package com.itextpdf.kernel.pdf.tagging
Class StructureTreeCopier
- java.lang.Object
-
- com.itextpdf.kernel.pdf.tagging.StructureTreeCopier
-
class StructureTreeCopier extends java.lang.Object
Internal helper class which is used to copy, clone or move tag structure across documents.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
StructureTreeCopier.CopyStructureResult
(package private) static class
StructureTreeCopier.LastClonedAncestor
private static class
StructureTreeCopier.StructElemCopyingParams
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<PdfName>
ignoreKeysForClone
private static java.util.List<PdfName>
ignoreKeysForCopy
-
Constructor Summary
Constructors Constructor Description StructureTreeCopier()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static PdfDictionary
addAllParentsToSet(PdfMcr mcr, java.util.Set<PdfObject> set)
private static void
cloneParents(PdfDictionary structElem, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document)
private static PdfDictionary
copyNamespaceDict(PdfDictionary srcNsDict, StructureTreeCopier.StructElemCopyingParams copyingParams)
private static PdfDictionary
copyObject(PdfDictionary source, PdfDictionary destPage, boolean parentChangePg, StructureTreeCopier.StructElemCopyingParams copyingParams)
private static PdfObject
copyObjectKid(PdfObject kid, PdfDictionary copiedParent, PdfDictionary destPage, boolean parentChangePg, StructureTreeCopier.StructElemCopyingParams copyingParams, PdfDictionary lastCopiedTrPage)
private static StructureTreeCopier.CopyStructureResult
copyStructure(PdfDocument destDocument, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument)
static void
copyTo(PdfDocument destDocument, int insertBeforePage, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument)
Copies structure to adestDocument
and insert it in a specified position in the document.private static void
copyTo(PdfDocument destDocument, int insertBeforePage, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument)
static void
copyTo(PdfDocument destDocument, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument)
Copies structure to adestDocument
.private static void
copyTo(PdfDocument destDocument, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument)
Copies structure to adestDocument
.private static void
copyTo(PdfDocument destDocument, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument, int insertIndex)
private static PdfDictionary
getTopmostParent(PdfMcr mcr)
Gets the topmost non-root structure element parent.static void
move(PdfDocument document, PdfPage from, int insertBefore)
Move tag structure of page to other place in the same documentprivate static java.util.List<PdfDictionary>
retrieveParents(PdfMcr mcr, boolean all)
private static void
separateKids(PdfDictionary structElem, java.util.Set<PdfObject> firstPartElems, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document)
private static int
separateStructure(PdfDocument document, int beforePage)
private static int
separateStructure(PdfDocument document, int startPage, int beforePage, int startPageStructTopIndex)
(package private) static boolean
shouldTableElementBeCopied(PdfDictionary obj, PdfDictionary parent)
-
-
-
Method Detail
-
copyTo
public static void copyTo(PdfDocument destDocument, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument)
Copies structure to adestDocument
.
NOTE: Works only forPdfStructTreeRoot
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 adestDocument
and insert it in a specified position in the document.
NOTE: Works only forPdfStructTreeRoot
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 movedinsertBefore
- 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 adestDocument
.- Parameters:
destDocument
- document to cpt structure to.page2page
- association between original page and copied page.copyFromDestDocument
- indicates ifpage2page
keys and values represent pages fromdestDocument
.
-
copyTo
private static void copyTo(PdfDocument destDocument, java.util.Map<PdfPage,PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument, int insertIndex)
-
copyStructure
private static StructureTreeCopier.CopyStructureResult copyStructure(PdfDocument destDocument, java.util.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, java.util.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, 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)
-
-