Class PdfString

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    PdfDate

    public class PdfString
    extends PdfObject
    A PdfString-class is the PDF-equivalent of a JAVA-String-object.

    A string is a sequence of characters delimited by parenthesis. If a string is too long to be conveniently placed on a single line, it may be split across multiple lines by using the backslash character (\) at the end of a line to indicate that the string continues on the following line. Within a string, the backslash character is used as an escape to specify unbalanced parenthesis, non-printing ASCII characters, and the backslash character itself. Use of the \ddd escape sequence is the preferred way to represent characters outside the printable ASCII character set.
    This object is described in the 'Portable Document Format Reference Manual version 1.7' section 3.2.3 (page 53-56).

    See Also:
    PdfObject, BadPdfFormatException, Serialized Form
    • Field Detail

      • value

        protected java.lang.String value
        The value of this object.
      • originalValue

        protected java.lang.String originalValue
      • encoding

        protected java.lang.String encoding
        The encoding.
      • objNum

        protected int objNum
      • objGen

        protected int objGen
      • hexWriting

        protected boolean hexWriting
    • Constructor Detail

      • PdfString

        public PdfString()
        Constructs an empty PdfString-object.
      • PdfString

        public PdfString​(java.lang.String value)
        Constructs a PdfString-object containing a string in the standard encoding TEXT_PDFDOCENCODING.
        Parameters:
        value - the content of the string
      • PdfString

        public PdfString​(java.lang.String value,
                         java.lang.String encoding)
        Constructs a PdfString-object containing a string in the specified encoding.
        Parameters:
        value - the content of the string
        encoding - an encoding
      • PdfString

        public PdfString​(byte[] bytes)
        Constructs a PdfString-object.
        Parameters:
        bytes - 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 PdfString as an array of byte to the specified OutputStream.
        Overrides:
        toPdf in class PdfObject
        Parameters:
        writer - for backwards compatibility
        os - The OutputStream to write the bytes to.
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Returns the String value of this PdfString-object.
        Overrides:
        toString in class PdfObject
        Returns:
        A String
      • getBytes

        public byte[] getBytes()
        Description copied from class: PdfObject
        Gets the presentation of this object in a byte array
        Overrides:
        getBytes in class PdfObject
        Returns:
        a byte array
      • toUnicodeString

        public java.lang.String toUnicodeString()
        Returns the Unicode String value of this PdfString-object.
        Returns:
        A String
      • getEncoding

        public java.lang.String getEncoding()
        Gets the encoding of this string.
        Returns:
        a String
      • setObjNum

        void setObjNum​(int objNum,
                       int objGen)
      • decrypt

        void decrypt​(PdfReader reader)
        Decrypt an encrypted PdfString
      • getOriginalBytes

        public byte[] getOriginalBytes()
      • setHexWriting

        public PdfString setHexWriting​(boolean hexWriting)
      • isHexWriting

        public boolean isHexWriting()