@@ -51,28 +51,52 @@ source product.
5151using iText . Kernel . Pdf . Filespec ;
5252
5353namespace 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>
5457 public class PdfStructTreeRoot : PdfObjectWrapper < PdfDictionary > , IStructureNode {
5558 private PdfDocument document ;
5659
5760 private ParentTreeHandler parentTreeHandler ;
5861
5962 private static IDictionary < String , PdfName > staticRoleNames = new ConcurrentDictionary < String , PdfName > ( ) ;
6063
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>
6173 public PdfStructTreeRoot ( PdfDocument document )
6274 : this ( ( PdfDictionary ) new PdfDictionary ( ) . MakeIndirect ( document ) , document ) {
6375 GetPdfObject ( ) . Put ( PdfName . Type , PdfName . StructTreeRoot ) ;
6476 }
6577
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 ) {
6889 this . document = document ;
6990 if ( this . document == null ) {
70- EnsureObjectIsAddedToDocument ( pdfObject ) ;
71- this . document = pdfObject . GetIndirectReference ( ) . GetDocument ( ) ;
91+ EnsureObjectIsAddedToDocument ( structTreeRootDict ) ;
92+ this . document = structTreeRootDict . GetIndirectReference ( ) . GetDocument ( ) ;
7293 }
7394 SetForbidRelease ( ) ;
7495 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.
76100 GetRoleMap ( ) ;
77101 }
78102
0 commit comments