@@ -44,8 +44,8 @@ This file is part of the iText (R) project.
44
44
package com .itextpdf .kernel .pdf .tagutils ;
45
45
46
46
import com .itextpdf .io .logs .IoLogMessageConstant ;
47
- import com .itextpdf .kernel .exceptions .PdfException ;
48
47
import com .itextpdf .kernel .exceptions .KernelExceptionMessageConstant ;
48
+ import com .itextpdf .kernel .exceptions .PdfException ;
49
49
import com .itextpdf .kernel .pdf .PdfArray ;
50
50
import com .itextpdf .kernel .pdf .PdfDictionary ;
51
51
import com .itextpdf .kernel .pdf .PdfDocument ;
@@ -64,7 +64,6 @@ This file is part of the iText (R) project.
64
64
import com .itextpdf .kernel .pdf .tagging .StandardNamespaces ;
65
65
import com .itextpdf .kernel .pdf .tagging .StandardRoles ;
66
66
67
-
68
67
import java .text .MessageFormat ;
69
68
import java .util .ArrayList ;
70
69
import java .util .Collection ;
@@ -119,6 +118,7 @@ public class TagStructureContext {
119
118
* <br>
120
119
* Creates {@code TagStructureContext} for document. There shall be only one instance of this
121
120
* class per {@code PdfDocument}.
121
+ *
122
122
* @param document the document which tag structure will be manipulated with this class.
123
123
*/
124
124
public TagStructureContext (PdfDocument document ) {
@@ -128,9 +128,11 @@ public TagStructureContext(PdfDocument document) {
128
128
/**
129
129
* Do not use this constructor, instead use {@link PdfDocument#getTagStructureContext()}
130
130
* method.
131
+ *
131
132
* <p>
132
133
* Creates {@code TagStructureContext} for document. There shall be only one instance of this
133
134
* class per {@code PdfDocument}.
135
+ *
134
136
* @param document the document which tag structure will be manipulated with this class.
135
137
* @param tagStructureTargetVersion the version of the pdf standard to which the tag structure shall adhere.
136
138
*/
@@ -156,14 +158,21 @@ public TagStructureContext(PdfDocument document, PdfVersion tagStructureTargetVe
156
158
* If forbidUnknownRoles is set to true, then if you would try to add new tag which has not a standard role and
157
159
* it's role is not mapped through RoleMap, an exception will be raised.
158
160
* Default value - true.
161
+ *
159
162
* @param forbidUnknownRoles new value of the flag
163
+ *
160
164
* @return current {@link TagStructureContext} instance.
161
165
*/
162
166
public TagStructureContext setForbidUnknownRoles (boolean forbidUnknownRoles ) {
163
167
this .forbidUnknownRoles = forbidUnknownRoles ;
164
168
return this ;
165
169
}
166
170
171
+ /**
172
+ * Gets the version of the PDF standard to which the tag structure shall adhere.
173
+ *
174
+ * @return the tag structure target version
175
+ */
167
176
public PdfVersion getTagStructureTargetVersion () {
168
177
return tagStructureTargetVersion ;
169
178
}
@@ -174,6 +183,7 @@ public PdfVersion getTagStructureTargetVersion() {
174
183
* Typically it points at the root tag. This pointer also could be used to tweak auto tagging process
175
184
* (e.g. move this pointer to the Section tag, which would result in placing all automatically tagged content
176
185
* under Section tag).
186
+ *
177
187
* @return the {@code TagTreePointer} which is used for all automatic tagging of the document.
178
188
*/
179
189
public TagTreePointer getAutoTaggingPointer () {
@@ -186,6 +196,7 @@ public TagTreePointer getAutoTaggingPointer() {
186
196
/**
187
197
* Gets {@link WaitingTagsManager} for the current document. It allows to mark tags as waiting,
188
198
* which would indicate that they are incomplete and are not ready to be flushed.
199
+ *
189
200
* @return document's {@link WaitingTagsManager} class instance.
190
201
*/
191
202
public WaitingTagsManager getWaitingTagsManager () {
@@ -199,8 +210,10 @@ public WaitingTagsManager getWaitingTagsManager() {
199
210
* <p>
200
211
* By default, this value is defined based on the PDF document version and the existing tag structure inside
201
212
* a document. For the new empty PDF 2.0 documents this namespace is set to {@link StandardNamespaces#PDF_2_0}.
213
+ *
202
214
* <p>
203
215
* This value has meaning only for the PDF documents of version <b>2.0 and higher</b>.
216
+ *
204
217
* @return a {@link PdfNamespace} which is used as a default value for the document tagging.
205
218
*/
206
219
public PdfNamespace getDocumentDefaultNamespace () {
@@ -210,16 +223,19 @@ public PdfNamespace getDocumentDefaultNamespace() {
210
223
/**
211
224
* Sets a namespace that will be used as a default value for the tagging for any new {@link TagTreePointer} created.
212
225
* See {@link #getDocumentDefaultNamespace()} for more info.
226
+ *
213
227
* <p>
214
228
* Be careful when changing this property value. It is most recommended to do it right after the {@link PdfDocument} was
215
229
* created, before any content was added. Changing this value after any content was added might result in the mingled
216
230
* tag structure from the namespaces point of view. So in order to maintain the document consistent but in the namespace
217
231
* different from default, set this value before any modifications to the document were made and before
218
232
* {@link #getAutoTaggingPointer()} method was called for the first time.
233
+ *
219
234
* <p>
220
235
* This value has meaning only for the PDF documents of version <b>2.0 and higher</b>.
221
236
*
222
237
* @param namespace a {@link PdfNamespace} which is to be used as a default value for the document tagging.
238
+ *
223
239
* @return current {@link TagStructureContext} instance.
224
240
*/
225
241
public TagStructureContext setDocumentDefaultNamespace (PdfNamespace namespace ) {
@@ -229,6 +245,7 @@ public TagStructureContext setDocumentDefaultNamespace(PdfNamespace namespace) {
229
245
230
246
/**
231
247
* This method defines a recommended way to obtain {@link PdfNamespace} class instances.
248
+ *
232
249
* <p>
233
250
* Returns either a wrapper over an already existing namespace dictionary in the document or over a new one
234
251
* if such namespace wasn't encountered before. Calling this method is considered as encountering a namespace,
@@ -239,6 +256,7 @@ public TagStructureContext setDocumentDefaultNamespace(PdfNamespace namespace) {
239
256
* {@link PdfName#Namespaces /Namespaces} array unless they were set to the certain element of the tag structure.
240
257
*
241
258
* @param namespaceName a {@link String} defining the namespace name (conventionally a uniform resource identifier, or URI).
259
+ *
242
260
* @return {@link PdfNamespace} wrapper over either already existing namespace object or over the new one.
243
261
*/
244
262
public PdfNamespace fetchNamespace (String namespaceName ) {
@@ -254,7 +272,9 @@ public PdfNamespace fetchNamespace(String namespaceName) {
254
272
/**
255
273
* Gets an instance of the {@link IRoleMappingResolver} corresponding to the current tag structure target version.
256
274
* This method implies that role is in the default standard structure namespace.
275
+ *
257
276
* @param role a role in the default standard structure namespace which mapping is to be resolved.
277
+ *
258
278
* @return a {@link IRoleMappingResolver} instance, with the giving role as current.
259
279
*/
260
280
public IRoleMappingResolver getRoleMappingResolver (String role ) {
@@ -263,8 +283,10 @@ public IRoleMappingResolver getRoleMappingResolver(String role) {
263
283
264
284
/**
265
285
* Gets an instance of the {@link IRoleMappingResolver} corresponding to the current tag structure target version.
286
+ *
266
287
* @param role a role in the given namespace which mapping is to be resolved.
267
288
* @param namespace a {@link PdfNamespace} which this role belongs to.
289
+ *
268
290
* @return a {@link IRoleMappingResolver} instance, with the giving role in the given {@link PdfNamespace} as current.
269
291
*/
270
292
public IRoleMappingResolver getRoleMappingResolver (String role , PdfNamespace namespace ) {
@@ -278,9 +300,11 @@ public IRoleMappingResolver getRoleMappingResolver(String role, PdfNamespace nam
278
300
/**
279
301
* Checks if the given role and namespace are specified to be obligatory mapped to the standard structure namespace
280
302
* in order to be a valid role in the Tagged PDF.
303
+ *
281
304
* @param role a role in the given namespace which mapping necessity is to be checked.
282
305
* @param namespace a {@link PdfNamespace} which this role belongs to, null value refers to the default standard
283
306
* structure namespace.
307
+ *
284
308
* @return true, if the given role in the given namespace is either mapped to the standard structure role or doesn't
285
309
* have to; otherwise false.
286
310
*/
@@ -290,10 +314,13 @@ public boolean checkIfRoleShallBeMappedToStandardRole(String role, PdfNamespace
290
314
291
315
/**
292
316
* Gets an instance of the {@link IRoleMappingResolver} which is already in the "resolved" state: it returns
293
- * role in the standard or domain-specific namespace for the {@link IRoleMappingResolver#getRole()} and {@link IRoleMappingResolver#getNamespace()}
294
- * methods calls which correspond to the mapping of the given role; or null if the given role is not mapped to the standard or domain-specific one.
317
+ * role in the standard or domain-specific namespace for the {@link IRoleMappingResolver#getRole()} and
318
+ * {@link IRoleMappingResolver#getNamespace()} methods calls which correspond to the mapping of the given role;
319
+ * or null if the given role is not mapped to the standard or domain-specific one.
320
+ *
295
321
* @param role a role in the given namespace which mapping is to be resolved.
296
322
* @param namespace a {@link PdfNamespace} which this role belongs to.
323
+ *
297
324
* @return an instance of the {@link IRoleMappingResolver} which returns false
298
325
* for the {@link IRoleMappingResolver#currentRoleShallBeMappedToStandard()} method call; if mapping cannot be resolved
299
326
* to this state, this method returns null, which means that the given role
@@ -323,6 +350,7 @@ public IRoleMappingResolver resolveMappingToStandardOrDomainSpecificRole(String
323
350
* If annotation is not added to the document or is not tagged, nothing will happen.
324
351
*
325
352
* @param annotation the {@link PdfAnnotation} that will be removed from the tag structure
353
+ *
326
354
* @return {@link TagTreePointer} instance which points at annotation tag parent if annotation was removed,
327
355
* otherwise returns null
328
356
*/
@@ -353,8 +381,10 @@ public TagTreePointer removeAnnotationTag(PdfAnnotation annotation) {
353
381
* Removes content item from the tag structure.
354
382
* <br>
355
383
* Nothing happens if there is no such mcid on given page.
384
+ *
356
385
* @param page page, which contains this content item
357
386
* @param mcid marked content id of this content item
387
+ *
358
388
* @return {@code TagTreePointer} which points at the parent of the removed content item, or null if there is no
359
389
* such mcid on given page.
360
390
*/
@@ -374,6 +404,7 @@ public TagTreePointer removeContentItem(PdfPage page, int mcid) {
374
404
* at {@link #flushPageTags(PdfPage)}.
375
405
*
376
406
* @param page page that defines which tags are to be removed
407
+ *
377
408
* @return current {@link TagStructureContext} instance
378
409
*/
379
410
public TagStructureContext removePageTags (PdfPage page ) {
@@ -402,6 +433,7 @@ public TagStructureContext removePageTags(PdfPage page) {
402
433
* as not yet finished ones, and they and their children won't be flushed.
403
434
*
404
435
* @param page a page which tags will be flushed
436
+ *
405
437
* @return current {@link TagStructureContext} instance
406
438
*/
407
439
public TagStructureContext flushPageTags (PdfPage page ) {
@@ -474,6 +506,7 @@ public void prepareToDocumentClosing() {
474
506
* especially in conjunction with high level {@link TagTreePointer} and {@link TagStructureContext} classes.
475
507
*
476
508
* @param pointer a {@link TagTreePointer} which points at desired {@link PdfStructElem}.
509
+ *
477
510
* @return a {@link PdfStructElem} at which given {@link TagTreePointer} points.
478
511
*/
479
512
public PdfStructElem getPointerStructElem (TagTreePointer pointer ) {
@@ -482,7 +515,9 @@ public PdfStructElem getPointerStructElem(TagTreePointer pointer) {
482
515
483
516
/**
484
517
* Creates a new {@link TagTreePointer} which points at given {@link PdfStructElem}.
518
+ *
485
519
* @param structElem a {@link PdfStructElem} for which {@link TagTreePointer} will be created.
520
+ *
486
521
* @return a new {@link TagTreePointer}.
487
522
*/
488
523
public TagTreePointer createPointerForStructElem (PdfStructElem structElem ) {
0 commit comments