Class PDFString

java.lang.Object
com.datalogics.PDFL.PDFObject
com.datalogics.PDFL.PDFString

public class PDFString extends PDFObject
Represents an array of unsigned bytes within a PDF document. A PDFString is a single data element that represents an array of unsigned bytes. It may be inserted into any collection object. PDFString may be a string of human readable text, but this is not required, and it may be stored either as characters or as hex values.

  • Constructor Details

    • PDFString

      public PDFString(byte[] value, Document doc, boolean indirect, boolean storedAsHex)
      General constructor

      Parameters:
      value - Array of bytes stored in this PDFString
      doc - Document object containing this PDFString
      indirect - flag marking this as an indirect PDFObject
      storedAsHex - flag indicating this PDFString should be stored as hex values
    • PDFString

      public PDFString(byte[] value, PDFObject docFromObj, boolean indirect, boolean storedAsHex)
      General constructor

      Parameters:
      value - Array of bytes stored in this PDFString
      docFromObj - The new PDFString will be created in the same document as this object.
      indirect - flag marking this as an indirect PDFObject
      storedAsHex - flag indicating this PDFString should be stored as hex values
    • PDFString

      public PDFString(String value, Document doc, boolean indirect, boolean storedAsHex, boolean storedAsUTF16)
      String constructor

      The provided string value is a Unicode string object. If storedAsUTF16 is true, it will be stored in the document at UTF-16BE. Otherwise it will be stored as PDFDocEncoding if it only contains characters within the PDFDocEncoding character set, else it will be stored as UTF-16BE.

      Parameters:
      value - String stored in this PDFString
      doc - Document object containing this PDFString
      indirect - flag marking this as an indirect PDFObject
      storedAsHex - flag indicating this PDFString should be stored as hex values
      storedAsUTF16 - flag indicating this PDFString should be stored as UTF-16BE, even if it could be encoded as PDFDocEncoding
    • PDFString

      public PDFString(String value, PDFObject docFromObj, boolean indirect, boolean storedAsHex, boolean storedAsUTF16)
      String constructor

      The provided string value is a Unicode string object. If storedAsUTF16 is true, it will be stored in the document at UTF-16BE. Otherwise it will be stored as PDFDocEncoding if it only contains characters within the PDFDocEncoding character set, else it will be stored as UTF-16BE.

      Parameters:
      value - String stored in this PDFString
      docFromObj - The new PDFString will be created in the same document as this object.
      indirect - flag marking this as an indirect PDFObject
      storedAsHex - flag indicating this PDFString should be stored as hex values
      storedAsUTF16 - flag indicating this PDFString should be stored as UTF-16BE, even if it could be encoded as PDFDocEncoding
    • PDFString

      public PDFString(String value, Document doc, boolean indirect, boolean storedAsHex)
      String constructor

      The provided string value is a Unicode string object. If it only contains characters within the PDFDocEncoding character set, it will be stored in that encoding; otherwise it will be stored in the document as UTF-16BE.

      Parameters:
      value - String stored in this PDFString
      doc - Document object containing this PDFString
      indirect - flag marking this as an indirect PDFObject
      storedAsHex - flag indicating this PDFString should be stored as hex values
    • PDFString

      public PDFString(String value, PDFObject docFromObj, boolean indirect, boolean storedAsHex)
      String constructor

      The provided string value is a Unicode string object. If it only contains characters within the PDFDocEncoding character set, it will be stored in that encoding; otherwise it will be stored in the document as UTF-16BE.

      Parameters:
      value - String stored in this PDFString
      docFromObj - The new PDFString will be created in the same document as this object.
      indirect - flag marking this as an indirect PDFObject
      storedAsHex - flag indicating this PDFString should be stored as hex values
  • Method Details

    • delete

      public void delete()
      Overrides:
      delete in class PDFObject
    • toString

      public String toString()
      Overrides:
      toString in class PDFObject
    • getBytes

      public byte[] getBytes()
      Byte array of this PDFString.

      This method returns the raw data of the PDFString, without respect to any encoding. It should be used when the contents of the object represent data instead of human readable text, or when direct access to the underlying data is required.

    • getValue

      public String getValue()
      The byte array as a native string object. This is a convenience for typical uses where a PDFString holds a human readable string instead of a byte array.

      The text may be encoded within the PDF as either UTF-16BE or PDFDocEncoding; in either case, it will be converted to a Unicode string object appropriate to the platform.

      If you need to access the contents of the PDFString object without respect to an encoding, use the Bytes property.

    • getStoredAsHex

      public boolean getStoredAsHex()
      Indicates that the data is stored as hexadecimal values.