iText 9.0.0 API
iText.Kernel.Pdf.PdfString Class Reference

A PdfString -class is the PDF-equivalent of a JAVA- String -object. More...

Inheritance diagram for iText.Kernel.Pdf.PdfString:
iText.Kernel.Pdf.PdfPrimitiveObject iText.Kernel.Pdf.PdfObject

Public Member Functions

  PdfString (String value, String encoding)
 
  PdfString (String value)
 
  PdfString (byte[] content)
 
override byte  GetObjectType ()
  Gets object type. More...
 
virtual bool  IsHexWriting ()
 
virtual iText.Kernel.Pdf.PdfString  SetHexWriting (bool hexWriting)
 
virtual String  GetValue ()
 
virtual String  GetEncoding ()
  Gets the encoding of this string. More...
 
virtual String  ToUnicodeString ()
  Returns the Unicode String value of this PdfString -object. More...
 
virtual byte[]  GetValueBytes ()
  Gets bytes of String-value considering encoding. More...
 
override bool  Equals (Object o)
 
override String  ToString ()
 
override int  GetHashCode ()
 
virtual void  MarkAsUnencryptedObject ()
  Marks this string object as not encrypted in the encrypted document. More...
 
- Public Member Functions inherited from iText.Kernel.Pdf.PdfPrimitiveObject
override PdfObject  MakeIndirect (PdfDocument document, PdfIndirectReference reference)
  Marks object to be saved as indirect. More...
 
- Public Member Functions inherited from iText.Kernel.Pdf.PdfObject
void  Flush ()
  Flushes the object to the document. More...
 
void  Flush (bool canBeInObjStm)
  Flushes the object to the document. More...
 
virtual PdfIndirectReference  GetIndirectReference ()
  Gets the indirect reference associated with the object. More...
 
virtual bool  IsIndirect ()
  Checks if object is indirect. More...
 
virtual PdfObject  MakeIndirect (PdfDocument document)
  Marks object to be saved as indirect. More...
 
virtual bool  IsFlushed ()
  Indicates is the object has been flushed or not. More...
 
virtual bool  IsModified ()
  Indicates is the object has been set as modified or not. More...
 
virtual PdfObject  Clone ()
  Creates clone of the object which belongs to the same document as original object. More...
 
virtual PdfObject  Clone (ICopyFilter filter)
  Creates clone of the object which belongs to the same document as original object. More...
 
virtual PdfObject  CopyTo (PdfDocument document)
  Copies object to a specified document. More...
 
virtual PdfObject  CopyTo (PdfDocument document, bool allowDuplicating)
  Copies object to a specified document. More...
 
virtual PdfObject  CopyTo (PdfDocument document, ICopyFilter copyFilter)
  Copies object to a specified document. More...
 
virtual PdfObject  CopyTo (PdfDocument document, bool allowDuplicating, ICopyFilter copyFilter)
  Copies object to a specified document. More...
 
virtual PdfObject  SetModified ()
  Sets the 'modified' flag to the indirect object, the flag denotes that the object was modified since the document opening. More...
 
virtual bool  IsReleaseForbidden ()
  Checks if it's forbidden to release this PdfObject instance. More...
 
virtual void  Release ()
 
virtual bool  IsNull ()
  Checks if this PdfObject is of the type PdfNull. More...
 
virtual bool  IsBoolean ()
  Checks if this PdfObject is of the type PdfBoolean. More...
 
virtual bool  IsNumber ()
  Checks if this PdfObject is of the type PdfNumber. More...
 
virtual bool  IsString ()
  Checks if this PdfObject is of the type PdfString. More...
 
virtual bool  IsName ()
  Checks if this PdfObject is of the type PdfName. More...
 
virtual bool  IsArray ()
  Checks if this PdfObject is of the type PdfArray. More...
 
virtual bool  IsDictionary ()
  Checks if this PdfObject is of the type PdfDictionary. More...
 
virtual bool  IsStream ()
  Checks if this PdfObject is of the type PdfStream. More...
 
virtual bool  IsIndirectReference ()
  Checks if this PdfObject is of the type PdfIndirectReference. More...
 
virtual bool  IsLiteral ()
  Checks if this PdfObject is of the type PdfLiteral. More...
 

Package Functions

  PdfString (byte[] content, bool hexWriting)
  Only PdfReader can use this method! More...
 
virtual void  GenerateValue ()
 
override void  GenerateContent ()
 
virtual bool  Encrypt (PdfEncryption encrypt)
  Encrypt content of value and set as content. More...
 
virtual byte[]  DecodeContent ()
 
virtual byte[]  EncodeBytes (byte[] bytes)
  Escape special symbols or convert to hexadecimal string. More...
 
override PdfObject  NewInstance ()
  Creates new instance of object. More...
 
override void  CopyContent (PdfObject from, PdfDocument document, ICopyFilter copyFilter)
  Copies object content from object 'from'. More...
 
- Package Functions inherited from iText.Kernel.Pdf.PdfPrimitiveObject
  PdfPrimitiveObject (bool directOnly)
 
  PdfPrimitiveObject (byte[] content)
  Initialize PdfPrimitiveObject from the passed bytes. More...
 
byte[]  GetInternalContent ()
 
virtual bool  HasContent ()
 
override PdfObject  SetIndirectReference (PdfIndirectReference indirectReference)
 
virtual int  CompareContent (iText.Kernel.Pdf.PdfPrimitiveObject o)
 
- Package Functions inherited from iText.Kernel.Pdf.PdfObject
virtual bool  CheckState (short state)
  Checks state of the flag of current object. More...
 
virtual PdfObject  SetState (short state)
  Sets special states of current object. More...
 
virtual PdfObject  ClearState (short state)
  Clear state of the flag of current object. More...
 
virtual void  CopyContent (PdfObject from, PdfDocument document)
  Copies object content from object 'from'. More...
 

Package Attributes

String  value
 
String  encoding
 
bool  hexWriting = false
 
- Package Attributes inherited from iText.Kernel.Pdf.PdfPrimitiveObject
byte[]  content = null
 
bool  directOnly
 
- Package Attributes inherited from iText.Kernel.Pdf.PdfObject
PdfIndirectReference  indirectReference = null
  If object is flushed the indirect reference is kept here. More...
 

Additional Inherited Members

- Static Public Attributes inherited from iText.Kernel.Pdf.PdfObject
const byte  ARRAY = 1
 
const byte  BOOLEAN = 2
 
const byte  DICTIONARY = 3
 
const byte  LITERAL = 4
 
const byte  INDIRECT_REFERENCE = 5
 
const byte  NAME = 6
 
const byte  NULL = 7
 
const byte  NUMBER = 8
 
const byte  STREAM = 9
 
const byte  STRING = 10
 
- Static Package Attributes inherited from iText.Kernel.Pdf.PdfObject
const short  FLUSHED = 1
  Indicates if the object has been flushed. More...
 
const short  FREE = 1 << 1
  Indicates that the indirect reference of the object could be reused or have to be marked as free. More...
 
const short  READING = 1 << 2
  Indicates that definition of the indirect reference of the object still not found (e.g. keys in XRefStm). More...
 
const short  MODIFIED = 1 << 3
  Indicates that object changed (is used in append mode). More...
 
const short  ORIGINAL_OBJECT_STREAM = 1 << 4
  Indicates that the indirect reference of the object represents ObjectStream from original document. More...
 
const short  MUST_BE_FLUSHED = 1 << 5
  Marks objects that shall be written to the output document. More...
 
const short  MUST_BE_INDIRECT = 1 << 6
  Indicates that the object shall be indirect when it is written to the document. More...
 
const short  FORBID_RELEASE = 1 << 7
  Indicates that the object is highly sensitive and we do not want to release it even if release() is called. More...
 
const short  READ_ONLY = 1 << 8
  Indicates that we do not want this object to be ever written into the resultant document (because of multiple objects read from the same reference inconsistency). More...
 
const short  UNENCRYPTED = 1 << 9
  Indicates that this object is not encrypted in the encrypted document. More...
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ PdfString()

iText.Kernel.Pdf.PdfString.PdfString ( byte[]  content,
bool  hexWriting 
)
inlinepackage

Only PdfReader can use this method!

Parameters
content byte content the PdfString will be created from
hexWriting boolean indicating if hex writing will be used

Member Function Documentation

◆ CopyContent()

override void iText.Kernel.Pdf.PdfString.CopyContent ( PdfObject  from,
PdfDocument  document,
ICopyFilter  filter 
)
inlinepackagevirtual

Copies object content from object 'from'.

Parameters
from object to copy content from.
document document to copy object to.
filter

iText.Kernel.Utils.ICopyFilter a filter that will apply on dictionaries and array Use iText.Kernel.Utils.NullCopyFilter for no filtering

Reimplemented from iText.Kernel.Pdf.PdfPrimitiveObject.

◆ EncodeBytes()

virtual byte [] iText.Kernel.Pdf.PdfString.EncodeBytes ( byte[]  bytes )
inlinepackagevirtual

Escape special symbols or convert to hexadecimal string.

Escape special symbols or convert to hexadecimal string. This method don't change either value or content ot the PdfString.

Parameters
bytes byte array to manipulate with.
Returns
Hexadecimal string or string with escaped symbols in byte array view.

◆ Encrypt()

virtual bool iText.Kernel.Pdf.PdfString.Encrypt ( PdfEncryption  encrypt )
inlinepackagevirtual

Encrypt content of value and set as content.

Encrypt content of value and set as content. generateContent() won't be called.

Parameters
encrypt

PdfEncryption instance

Returns
true if value was encrypted, otherwise false.

◆ GetEncoding()

virtual String iText.Kernel.Pdf.PdfString.GetEncoding ( )
inlinevirtual

Gets the encoding of this string.

Returns
the name of the encoding specifying the byte representation of current PdfString value

◆ GetObjectType()

override byte iText.Kernel.Pdf.PdfString.GetObjectType ( )
inlinevirtual

Gets object type.

Returns
object type.

Implements iText.Kernel.Pdf.PdfObject.

◆ GetValueBytes()

virtual byte [] iText.Kernel.Pdf.PdfString.GetValueBytes ( )
inlinevirtual

Gets bytes of String-value considering encoding.

Returns
byte array

◆ MarkAsUnencryptedObject()

virtual void iText.Kernel.Pdf.PdfString.MarkAsUnencryptedObject ( )
inlinevirtual

Marks this string object as not encrypted in the encrypted document.

Marks this string object as not encrypted in the encrypted document.

If it's marked so, it will be considered as already in plaintext and decryption will not be performed for it. In order to have effect, this method shall be called before GetValue() and GetValueBytes() methods.

NOTE: this method is only needed in a very specific cases of encrypted documents. E.g. digital signature dictionary /Contents entry shall not be encrypted. Also this method isn't meaningful in non-encrypted documents.

◆ NewInstance()

override PdfObject iText.Kernel.Pdf.PdfString.NewInstance ( )
inlinepackagevirtual

Creates new instance of object.

Returns
new instance of object.

Implements iText.Kernel.Pdf.PdfObject.

◆ ToUnicodeString()

virtual String iText.Kernel.Pdf.PdfString.ToUnicodeString ( )
inlinevirtual

Returns the Unicode String value of this PdfString -object.

Returns
Unicode string value created by current PdfString object