Skip to content

Commit 3304ecd

Browse files
Improve StructTreeRoot documentation
DEVSIX-4812 Autoported commit. Original commit hash: [1d4e2c754]
1 parent f0ffe30 commit 3304ecd

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

itext/itext.kernel/itext/kernel/pdf/PdfDocument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ public virtual iText.Kernel.Pdf.PdfDocument SetTagged() {
939939
/// <returns>
940940
///
941941
/// <see cref="iText.Kernel.Pdf.Tagging.PdfStructTreeRoot"/>
942-
/// in case tagged document, otherwise false.
942+
/// in case document is tagged, otherwise it returns null.
943943
/// </returns>
944944
/// <seealso cref="IsTagged()"/>
945945
/// <seealso cref="GetNextStructParentIndex()"/>

itext/itext.kernel/itext/kernel/pdf/tagging/PdfStructTreeRoot.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,52 @@ source product.
5151
using iText.Kernel.Pdf.Filespec;
5252

5353
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>
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

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9a47f5f698e7cfccda49810bff84abcd45368154
1+
f8771af2f52833c1c967a729a80ebb4d6b14056f

0 commit comments

Comments
 (0)