Class PdfObject

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ARRAY
      A possible type of PdfObject
      (package private) static int BOOLEAN
      A possible type of PdfObject
      protected byte[] bytes
      The content of this PdfObject
      (package private) static int DICTIONARY
      A possible type of PdfObject
      static int INDIRECT
      A possible type of PdfObject
      private PRIndirectReference indRef
      Holds the indirect reference.
      (package private) static int NAME
      A possible type of PdfObject
      (package private) static java.lang.String NOTHING
      An empty string used for the PdfNull-object and for an empty PdfString-object.
      (package private) static int NULL
      A possible type of PdfObject
      (package private) static int NUMBER
      A possible type of PdfObject
      static int STREAM
      A possible type of PdfObject
      (package private) static int STRING
      A possible type of PdfObject
      (package private) static java.lang.String TEXT_PDFDOCENCODING
      This is the default encoding to be used for converting Strings into bytes and vice versa.
      static java.lang.String TEXT_UNICODE
      This is the encoding to be used to output text in Unicode.
      protected int type
      The type of this PdfObject
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PdfObject​(int type)
      Constructs a PdfObject of a certain type without any content.
      protected PdfObject​(int type, byte[] bytes)
      Constructs a PdfObject of a certain type with a certain content.
      protected PdfObject​(int type, java.lang.String content)
      Constructs a PdfObject of a certain type with a certain content.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) boolean canBeInObjStm()
      Whether this object can be contained in an object stream.
      byte[] getBytes()
      Gets the presentation of this object in a byte array
      PRIndirectReference getIndRef()
      Get the indirect reference
      boolean isArray()
      Checks if this PdfObject is of the type PdfArray.
      boolean isBoolean()
      Checks if this PdfObject is of the type PdfBoolean.
      boolean isDictionary()
      Checks if this PdfObject is of the type PdfDictionary.
      boolean isIndirect()
      Checks if this PdfObject is of the type PdfIndirectObject.
      boolean isName()
      Checks if this PdfObject is of the type PdfName.
      boolean isNull()
      Checks if this PdfObject is of the type PdfNull.
      boolean isNumber()
      Checks if this PdfObject is of the type PdfNumber.
      boolean isStream()
      Checks if this PdfObject is of the type PdfStream.
      boolean isString()
      Checks if this PdfObject is of the type PdfString.
      protected void setContent​(java.lang.String content)
      Changes the content of this PdfObject.
      void setIndRef​(PRIndirectReference indRef)
      Set the indirect reference
      void toPdf​(PdfWriter writer, java.io.OutputStream os)
      Writes the PDF representation of this PdfObject as an array of bytes to the writer.
      java.lang.String toString()
      Returns the String-representation of this PdfObject.
      int type()
      Returns the type of this PdfObject.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • INDIRECT

        public static final int INDIRECT
        A possible type of PdfObject
        See Also:
        Constant Field Values
      • NOTHING

        static final java.lang.String NOTHING
        An empty string used for the PdfNull-object and for an empty PdfString-object.
        See Also:
        Constant Field Values
      • TEXT_PDFDOCENCODING

        static final java.lang.String TEXT_PDFDOCENCODING
        This is the default encoding to be used for converting Strings into bytes and vice versa. The default encoding is PdfDocEncoding.
        See Also:
        Constant Field Values
      • TEXT_UNICODE

        public static final java.lang.String TEXT_UNICODE
        This is the encoding to be used to output text in Unicode.
        See Also:
        Constant Field Values
      • bytes

        protected byte[] bytes
        The content of this PdfObject
      • type

        protected int type
        The type of this PdfObject
    • Constructor Detail

      • PdfObject

        protected PdfObject​(int type)
        Constructs a PdfObject of a certain type without any content.
        Parameters:
        type - type of the new PdfObject
      • PdfObject

        protected PdfObject​(int type,
                            java.lang.String content)
        Constructs a PdfObject of a certain type with a certain content.
        Parameters:
        type - type of the new PdfObject
        content - content of the new PdfObject as a String.
      • PdfObject

        protected PdfObject​(int type,
                            byte[] bytes)
        Constructs a PdfObject of a certain type with a certain content.
        Parameters:
        type - type of the new PdfObject
        bytes - content of the new PdfObject as an array of byte.
    • Method Detail

      • toPdf

        public void toPdf​(PdfWriter writer,
                          java.io.OutputStream os)
                   throws java.io.IOException
        Writes the PDF representation of this PdfObject as an array of bytes to the writer.
        Parameters:
        writer - for backwards compatibility
        os - The OutputStream to write the bytes to.
        Throws:
        java.io.IOException - Exception with a I/O error
      • toString

        public java.lang.String toString()
        Returns the String-representation of this PdfObject.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String
      • getBytes

        public byte[] getBytes()
        Gets the presentation of this object in a byte array
        Returns:
        a byte array
      • canBeInObjStm

        boolean canBeInObjStm()
        Whether this object can be contained in an object stream. PdfObjects of type STREAM OR INDIRECT can not be contained in an object stream.
        Returns:
        true if this object can be in an object stream. Otherwise false
      • setContent

        protected void setContent​(java.lang.String content)
        Changes the content of this PdfObject.
        Parameters:
        content - the new content of this PdfObject
      • type

        public int type()
        Returns the type of this PdfObject. May be either of: - NULL: A PdfNull - BOOLEAN: A PdfBoolean - NUMBER: A PdfNumber - STRING: A PdfString - NAME: A PdfName - ARRAY: A PdfArray - DICTIONARY: A PdfDictionary - STREAM: A PdfStream - INDIRECT: A PdfIndirectObject
        Returns:
        The type
      • isNull

        public boolean isNull()
        Checks if this PdfObject is of the type PdfNull.
        Returns:
        true or false
      • isBoolean

        public boolean isBoolean()
        Checks if this PdfObject is of the type PdfBoolean.
        Returns:
        true or false
      • isNumber

        public boolean isNumber()
        Checks if this PdfObject is of the type PdfNumber.
        Returns:
        true or false
      • isString

        public boolean isString()
        Checks if this PdfObject is of the type PdfString.
        Returns:
        true or false
      • isName

        public boolean isName()
        Checks if this PdfObject is of the type PdfName.
        Returns:
        true or false
      • isArray

        public boolean isArray()
        Checks if this PdfObject is of the type PdfArray.
        Returns:
        true or false
      • isDictionary

        public boolean isDictionary()
        Checks if this PdfObject is of the type PdfDictionary.
        Returns:
        true or false
      • isStream

        public boolean isStream()
        Checks if this PdfObject is of the type PdfStream.
        Returns:
        true or false
      • isIndirect

        public boolean isIndirect()
        Checks if this PdfObject is of the type PdfIndirectObject.
        Returns:
        true if this is an indirect object, otherwise false
      • getIndRef

        public PRIndirectReference getIndRef()
        Get the indirect reference
        Returns:
        A PdfIndirectReference
      • setIndRef

        public void setIndRef​(PRIndirectReference indRef)
        Set the indirect reference
        Parameters:
        indRef - New value as a PdfIndirectReference