@@ -51,28 +51,52 @@ source product.
51
51
using iText . Kernel . Pdf . Filespec ;
52
52
53
53
namespace iText . Kernel . Pdf . Tagging {
54
+ /// <summary>Represents a wrapper-class for structure tree root dictionary.</summary>
55
+ /// <remarks>Represents a wrapper-class for structure tree root dictionary. See ISO-32000-1 "14.7.2 Structure hierarchy".
56
+ /// </remarks>
54
57
public class PdfStructTreeRoot : PdfObjectWrapper < PdfDictionary > , IStructureNode {
55
58
private PdfDocument document ;
56
59
57
60
private ParentTreeHandler parentTreeHandler ;
58
61
59
62
private static IDictionary < String , PdfName > staticRoleNames = new ConcurrentDictionary < String , PdfName > ( ) ;
60
63
64
+ /// <summary>Creates a new structure tree root instance, this initializes empty logical structure in the document.
65
+ /// </summary>
66
+ /// <remarks>
67
+ /// Creates a new structure tree root instance, this initializes empty logical structure in the document.
68
+ /// This class also handles global state of parent tree, so it's not expected to create multiple instances
69
+ /// of this class. Instead, use
70
+ /// <see cref="iText.Kernel.Pdf.PdfDocument.GetStructTreeRoot()"/>.
71
+ /// </remarks>
72
+ /// <param name="document">a document to which new instance of struct tree root will be bound</param>
61
73
public PdfStructTreeRoot ( PdfDocument document )
62
74
: this ( ( PdfDictionary ) new PdfDictionary ( ) . MakeIndirect ( document ) , document ) {
63
75
GetPdfObject ( ) . Put ( PdfName . Type , PdfName . StructTreeRoot ) ;
64
76
}
65
77
66
- public PdfStructTreeRoot ( PdfDictionary pdfObject , PdfDocument document )
67
- : base ( pdfObject ) {
78
+ /// <summary>Creates wrapper instance for already existing logical structure tree root in the document.</summary>
79
+ /// <remarks>
80
+ /// Creates wrapper instance for already existing logical structure tree root in the document.
81
+ /// This class also handles global state of parent tree, so it's not expected to create multiple instances
82
+ /// of this class. Instead, use
83
+ /// <see cref="iText.Kernel.Pdf.PdfDocument.GetStructTreeRoot()"/>.
84
+ /// </remarks>
85
+ /// <param name="structTreeRootDict">a dictionary that defines document structure tree root</param>
86
+ /// <param name="document">a document, which contains given structure tree root dictionary</param>
87
+ public PdfStructTreeRoot ( PdfDictionary structTreeRootDict , PdfDocument document )
88
+ : base ( structTreeRootDict ) {
68
89
this . document = document ;
69
90
if ( this . document == null ) {
70
- EnsureObjectIsAddedToDocument ( pdfObject ) ;
71
- this . document = pdfObject . GetIndirectReference ( ) . GetDocument ( ) ;
91
+ EnsureObjectIsAddedToDocument ( structTreeRootDict ) ;
92
+ this . document = structTreeRootDict . GetIndirectReference ( ) . GetDocument ( ) ;
72
93
}
73
94
SetForbidRelease ( ) ;
74
95
parentTreeHandler = new ParentTreeHandler ( this ) ;
75
- // TODO may be remove?
96
+ // Always init role map dictionary in order to avoid inconsistency, because
97
+ // iText often initializes it during role mapping resolution anyway.
98
+ // In future, better way might be to not write it to the document needlessly
99
+ // and avoid possible redundant modifications in append mode.
76
100
GetRoleMap ( ) ;
77
101
}
78
102
0 commit comments