Class StructureTreeCopier
java.lang.Object
com.itextpdf.kernel.pdf.tagging.StructureTreeCopier
Internal helper class which is used to copy, clone or move tag structure across documents.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PdfDictionaryaddAllParentsToSet(PdfMcr mcr, Set<PdfObject> set) private static voidcloneParents(PdfDictionary structElem, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document) private static PdfDictionarycopyNamespaceDict(PdfDictionary srcNsDict, StructureTreeCopier.StructElemCopyingParams copyingParams) private static PdfDictionarycopyObject(PdfDictionary source, PdfDictionary destPage, boolean parentChangePg, StructureTreeCopier.StructElemCopyingParams copyingParams) private static PdfObjectcopyObjectKid(PdfObject kid, PdfDictionary copiedParent, PdfDictionary destPage, boolean parentChangePg, StructureTreeCopier.StructElemCopyingParams copyingParams, PdfDictionary lastCopiedTrPage) private static StructureTreeCopier.CopyStructureResultcopyStructure(PdfDocument destDocument, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument) static voidcopyTo(PdfDocument destDocument, int insertBeforePage, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument) Copies structure to adestDocumentand insert it in a specified position in the document.private static voidcopyTo(PdfDocument destDocument, int insertBeforePage, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument) static voidcopyTo(PdfDocument destDocument, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument) Copies structure to adestDocument.private static voidcopyTo(PdfDocument destDocument, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument) Copies structure to adestDocument.private static voidcopyTo(PdfDocument destDocument, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument, boolean copyFromDestDocument, int insertIndex) private static PdfDictionarygetTopmostParent(PdfMcr mcr) Gets the topmost non-root structure element parent.static voidmove(PdfDocument document, PdfPage from, int insertBefore) Move tag structure of page to other place in the same documentprivate static List<PdfDictionary> retrieveParents(PdfMcr mcr, boolean all) private static voidseparateKids(PdfDictionary structElem, Set<PdfObject> firstPartElems, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document) private static intseparateStructure(PdfDocument document, int beforePage) private static intseparateStructure(PdfDocument document, int startPage, int beforePage, int startPageStructTopIndex) (package private) static booleanshouldTableElementBeCopied(PdfDictionary obj, PdfDictionary parent)
-
Field Details
-
ignoreKeysForCopy
-
ignoreKeysForClone
-
-
Constructor Details
-
StructureTreeCopier
StructureTreeCopier()
-
-
Method Details
-
copyTo
public static void copyTo(PdfDocument destDocument, Map<PdfPage, PdfPage> page2page, PdfDocument callingDocument) Copies structure to adestDocument.
NOTE: Works only forPdfStructTreeRootthat 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 adestDocumentand insert it in a specified position in the document.
NOTE: Works only forPdfStructTreeRootthat 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
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
- 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 adestDocument.- Parameters:
destDocument- document to cpt structure to.page2page- association between original page and copied page.copyFromDestDocument- indicates ifpage2pagekeys and values represent pages fromdestDocument.
-
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
-
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
- Returns:
- the topmost parent added to set. If encountered flushed element - stops and returns this flushed element.
-
getTopmostParent
Gets the topmost non-root structure element parent. May be flushed.- Parameters:
mcr- starting element- Returns:
- topmost non-root structure element parent, or
nullif it doesn't have any
-
retrieveParents
-