Package com.itextpdf.kernel.pdf.tagging
Class PdfNamespace
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.kernel.pdf.tagging.PdfNamespace
A wrapper for namespace dictionaries (ISO 32000-2 section 14.7.4). A namespace dictionary defines a namespace within the structure tree.
This pdf entity is meaningful only for the PDF documents of version 2.0 and higher.
-
Constructor Summary
ConstructorsConstructorDescriptionPdfNamespace(PdfDictionary dictionary) Constructs namespace from the givenPdfDictionarythat represents namespace dictionary.PdfNamespace(PdfString namespaceName) Constructs a namespace defined by the given namespace name.PdfNamespace(String namespaceName) Constructs a namespace defined by the given namespace name. -
Method Summary
Modifier and TypeMethodDescriptionaddNamespaceRoleMapping(String thisNsRole, String defaultNsRole) Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)) a single role mapping to the default standard structure namespace.addNamespaceRoleMapping(String thisNsRole, String targetNsRole, PdfNamespace targetNs) Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)) a single role mapping to the target namespace.static PdfNamespacegetDefault(PdfDocument pdfDocument) Retrieves default namespace from provided document or adds a new one in case it's absent.Gets the string defining the namespace name.A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.Gets file specification identifying the schema file, which defines this namespace.protected booleanDefines if the object behind this wrapper must be an indirect object in the resultant document.setNamespaceName(PdfString namespaceName) Sets the string defining the namespace name.setNamespaceName(String namespaceName) Sets the string defining the namespace name.setNamespaceRoleMap(PdfDictionary roleMapNs) A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.setSchema(PdfFileSpec fileSpec) Sets file specification identifying the schema file, which defines this namespace.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Constructor Details
-
PdfNamespace
Constructs namespace from the givenPdfDictionarythat represents namespace dictionary. This method is useful for property reading in reading mode or modifying in stamping mode.- Parameters:
-
dictionary- aPdfDictionarythat represents namespace in the document.
-
PdfNamespace
Constructs a namespace defined by the given namespace name.- Parameters:
-
namespaceName- aStringdefining the namespace name (conventionally a uniform resource identifier, or URI).
-
PdfNamespace
Constructs a namespace defined by the given namespace name.- Parameters:
-
namespaceName- aPdfStringdefining the namespace name (conventionally a uniform resource identifier, or URI).
-
-
Method Details
-
getDefault
Retrieves default namespace from provided document or adds a new one in case it's absent.- Parameters:
-
pdfDocument-documentto retrieve the namespace instance - Returns:
- default namespace instance
-
setNamespaceName
Sets the string defining the namespace name.- Parameters:
-
namespaceName- aStringdefining the namespace name (conventionally a uniform resource identifier, or URI). - Returns:
-
this
PdfNamespaceinstance.
-
setNamespaceName
Sets the string defining the namespace name.- Parameters:
-
namespaceName- aPdfStringdefining the namespace name (conventionally a uniform resource identifier, or URI). - Returns:
-
this
PdfNamespaceinstance.
-
getNamespaceName
Gets the string defining the namespace name.- Returns:
-
a
Stringdefining the namespace name (conventionally a uniform resource identifier, or URI).
-
setSchema
Sets file specification identifying the schema file, which defines this namespace.- Parameters:
-
fileSpec- aPdfFileSpecidentifying the schema file. - Returns:
-
this
PdfNamespaceinstance.
-
getSchema
Gets file specification identifying the schema file, which defines this namespace.- Returns:
-
a
PdfFileSpecidentifying the schema file.
-
setNamespaceRoleMap
A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.- Parameters:
-
roleMapNs- aPdfDictionarywhich is comprised of a set of keys representing structure element types in the namespace defined within this namespace dictionary. The corresponding value for each of these keys shall either be a singlePdfNameidentifying a structure element type in the default namespace or anPdfArraywhere the first value shall be a structure element type name in a target namespace with the second value being an indirect reference to the target namespace dictionary. - Returns:
-
this
PdfNamespaceinstance.
-
getNamespaceRoleMap
A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.- Returns:
-
a
PdfDictionarywhich is comprised of a set of keys representing structure element types in the namespace defined within this namespace dictionary. The corresponding value for each of these keys shall either be a singlePdfNameidentifying a structure element type in the default namespace or anPdfArraywhere the first value shall be a structure element type name in a target namespace with the second value being an indirect reference to the target namespace dictionary.
-
addNamespaceRoleMapping
Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)) a single role mapping to the default standard structure namespace.- Parameters:
-
thisNsRole- aStringidentifying structure element type in this namespace. -
defaultNsRole- aStringidentifying a structure element type in the default standard structure namespace. - Returns:
-
this
PdfNamespaceinstance.
-
addNamespaceRoleMapping
public PdfNamespace addNamespaceRoleMapping(String thisNsRole, String targetNsRole, PdfNamespace targetNs) Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)) a single role mapping to the target namespace.- Parameters:
-
thisNsRole- aStringidentifying structure element type in this namespace. -
targetNsRole- aStringidentifying a structure element type in the target namespace. -
targetNs- aPdfNamespaceidentifying the target namespace. - Returns:
-
this
PdfNamespaceinstance.
-
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapperDefines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
-
isWrappedObjectMustBeIndirectin classPdfObjectWrapper<PdfDictionary> - Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-