Package com.itextpdf.kernel.pdf.tagging
Class PdfNamespace
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
-
- com.itextpdf.kernel.pdf.tagging.PdfNamespace
-
public class PdfNamespace extends PdfObjectWrapper<PdfDictionary>
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
Constructors Constructor Description PdfNamespace(PdfDictionary dictionary)Constructs namespace from the givenPdfDictionarythat represents namespace dictionary.PdfNamespace(PdfString namespaceName)Constructs a namespace defined by the given namespace name.PdfNamespace(java.lang.String namespaceName)Constructs a namespace defined by the given namespace name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PdfNamespaceaddNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String defaultNsRole)Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)) a single role mapping to the default standard structure namespace.PdfNamespaceaddNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String targetNsRole, PdfNamespace targetNs)Adds to the namespace role map (seesetNamespaceRoleMap(PdfDictionary)) a single role mapping to the target namespace.java.lang.StringgetNamespaceName()Gets the string defining the namespace name.PdfDictionarygetNamespaceRoleMap()A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.private PdfDictionarygetNamespaceRoleMap(boolean createIfNotExist)PdfFileSpecgetSchema()Gets file specification identifying the schema file, which defines this namespace.protected booleanisWrappedObjectMustBeIndirect()Defines if the object behind this wrapper must be an indirect object in the resultant document.private voidlogOverwritingOfMappingIfNeeded(java.lang.String thisNsRole, PdfObject prevVal)private PdfNamespaceput(PdfName key, PdfObject value)PdfNamespacesetNamespaceName(PdfString namespaceName)Sets the string defining the namespace name.PdfNamespacesetNamespaceName(java.lang.String namespaceName)Sets the string defining the namespace name.PdfNamespacesetNamespaceRoleMap(PdfDictionary roleMapNs)A dictionary that maps the names of structure types used in the namespace to their approximate equivalents in another namespace.PdfNamespacesetSchema(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 Detail
-
PdfNamespace
public PdfNamespace(PdfDictionary dictionary)
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
public PdfNamespace(java.lang.String namespaceName)
Constructs a namespace defined by the given namespace name.- Parameters:
namespaceName- aStringdefining the namespace name (conventionally a uniform resource identifier, or URI).
-
-
Method Detail
-
setNamespaceName
public PdfNamespace setNamespaceName(java.lang.String namespaceName)
Sets the string defining the namespace name.- Parameters:
namespaceName- aStringdefining the namespace name (conventionally a uniform resource identifier, or URI).- Returns:
- this
PdfNamespaceinstance.
-
setNamespaceName
public PdfNamespace setNamespaceName(PdfString namespaceName)
Sets the string defining the namespace name.- Parameters:
namespaceName- aPdfStringdefining the namespace name (conventionally a uniform resource identifier, or URI).- Returns:
- this
PdfNamespaceinstance.
-
getNamespaceName
public java.lang.String getNamespaceName()
Gets the string defining the namespace name.- Returns:
- a
Stringdefining the namespace name (conventionally a uniform resource identifier, or URI).
-
setSchema
public PdfNamespace setSchema(PdfFileSpec fileSpec)
Sets file specification identifying the schema file, which defines this namespace.- Parameters:
fileSpec- aPdfFileSpecidentifying the schema file.- Returns:
- this
PdfNamespaceinstance.
-
getSchema
public PdfFileSpec getSchema()
Gets file specification identifying the schema file, which defines this namespace.- Returns:
- a
PdfFileSpecidentifying the schema file.
-
setNamespaceRoleMap
public PdfNamespace setNamespaceRoleMap(PdfDictionary roleMapNs)
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
public PdfDictionary 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
public PdfNamespace addNamespaceRoleMapping(java.lang.String thisNsRole, java.lang.String defaultNsRole)
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(java.lang.String thisNsRole, java.lang.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.
-
put
private PdfNamespace put(PdfName key, PdfObject value)
-
getNamespaceRoleMap
private PdfDictionary getNamespaceRoleMap(boolean createIfNotExist)
-
logOverwritingOfMappingIfNeeded
private void logOverwritingOfMappingIfNeeded(java.lang.String thisNsRole, PdfObject prevVal)
-
-