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 Details

    • PdfNamespace

      public PdfNamespace (PdfDictionary dictionary)
      Constructs namespace from the given PdfDictionary that represents namespace dictionary. This method is useful for property reading in reading mode or modifying in stamping mode.
      Parameters:
      dictionary - a PdfDictionary that represents namespace in the document.
    • PdfNamespace

      public PdfNamespace (String namespaceName)
      Constructs a namespace defined by the given namespace name.
      Parameters:
      namespaceName - a String defining the namespace name (conventionally a uniform resource identifier, or URI).
    • PdfNamespace

      public PdfNamespace (PdfString namespaceName)
      Constructs a namespace defined by the given namespace name.
      Parameters:
      namespaceName - a PdfString defining the namespace name (conventionally a uniform resource identifier, or URI).
  • Method Details

    • setNamespaceName

      public PdfNamespace setNamespaceName (String namespaceName)
      Sets the string defining the namespace name.
      Parameters:
      namespaceName - a String defining the namespace name (conventionally a uniform resource identifier, or URI).
      Returns:
      this PdfNamespace instance.
    • setNamespaceName

      public PdfNamespace setNamespaceName (PdfString namespaceName)
      Sets the string defining the namespace name.
      Parameters:
      namespaceName - a PdfString defining the namespace name (conventionally a uniform resource identifier, or URI).
      Returns:
      this PdfNamespace instance.
    • getNamespaceName

      public String getNamespaceName()
      Gets the string defining the namespace name.
      Returns:
      a String defining 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 - a PdfFileSpec identifying the schema file.
      Returns:
      this PdfNamespace instance.
    • getSchema

      public PdfFileSpec getSchema()
      Gets file specification identifying the schema file, which defines this namespace.
      Returns:
      a PdfFileSpec identifying 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 - a PdfDictionary which 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 single PdfName identifying a structure element type in the default namespace or an PdfArray where 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 PdfNamespace instance.
    • 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 PdfDictionary which 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 single PdfName identifying a structure element type in the default namespace or an PdfArray where 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 (String thisNsRole, String defaultNsRole)
      Adds to the namespace role map (see setNamespaceRoleMap(PdfDictionary)) a single role mapping to the default standard structure namespace.
      Parameters:
      thisNsRole - a String identifying structure element type in this namespace.
      defaultNsRole - a String identifying a structure element type in the default standard structure namespace.
      Returns:
      this PdfNamespace instance.
    • addNamespaceRoleMapping

      public PdfNamespace addNamespaceRoleMapping (String thisNsRole, String targetNsRole, PdfNamespace targetNs)
      Adds to the namespace role map (see setNamespaceRoleMap(PdfDictionary)) a single role mapping to the target namespace.
      Parameters:
      thisNsRole - a String identifying structure element type in this namespace.
      targetNsRole - a String identifying a structure element type in the target namespace.
      targetNs - a PdfNamespace identifying the target namespace.
      Returns:
      this PdfNamespace instance.
    • isWrappedObjectMustBeIndirect

      protected boolean isWrappedObjectMustBeIndirect()
      Description copied from class: PdfObjectWrapper
      Defines 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:
      isWrappedObjectMustBeIndirect in class PdfObjectWrapper<PdfDictionary>
      Returns:
      true if in the resultant document the object behind the wrapper must be indirect, otherwise false.