com.lowagie.text.pdf

Class PdfObject

public abstract class PdfObject extends Object

PdfObject is the abstract superclass of all PDF objects.

PDF supports seven basic types of objects: Booleans, numbers, strings, names, arrays, dictionaries and streams. In addition, PDF provides a null object. Objects may be labeled so that they can be referred to by other objects.
All these basic PDF objects are described in the 'Portable Document Format Reference Manual version 1.3' Chapter 4 (pages 37-54).

See Also: PdfNull PdfBoolean PdfNumber PdfString PdfName PdfArray PdfDictionary PdfStream PdfIndirectReference

Field Summary
static intARRAY
a possible type of PdfObject
protected byte[]bytes
the content of this PdfObject
static intBOOLEAN
a possible type of PdfObject
static intDICTIONARY
a possible type of PdfObject
protected PRIndirectReferenceindRef
Holds value of property indRef.
static intINDIRECT
a possible type of PdfObject
static intNAME
a possible type of PdfObject
static StringNOTHING
This is an empty string used for the PdfNull-object and for an empty PdfString-object.
static intNULL
a possible type of PdfObject
static intNUMBER
a possible type of PdfObject
static intSTREAM
a possible type of PdfObject
static intSTRING
a possible type of PdfObject
protected inttype
the type of this PdfObject
static StringTEXT_PDFDOCENCODING
This is the default encoding to be used for converting Strings into bytes and vice versa.
static StringTEXT_UNICODE
This is the encoding to be used to output text in Unicode.
Constructor Summary
protected PdfObject(int type)
Constructs a PdfObject of a certain type without any content.
protected PdfObject(int type, String content)
Constructs a PdfObject of a certain type with a certain content.
protected PdfObject(int type, byte[] bytes)
Constructs a PdfObject of a certain type with a certain content.
Method Summary
booleancanBeInObjStm()
Can this object be in an object stream?
byte[]getBytes()
Gets the presentation of this object in a byte array
PRIndirectReferencegetIndRef()
Getter for property indRef.
booleanisArray()
Checks if this PdfObject is of the type PdfArray.
booleanisBoolean()
Checks if this PdfObject is of the type PdfBoolean.
booleanisDictionary()
Checks if this PdfObject is of the type PdfDictionary.
booleanisIndirect()
Checks if this is an indirect object.
booleanisName()
Checks if this PdfObject is of the type PdfName.
booleanisNull()
Checks if this PdfObject is of the type PdfNull.
booleanisNumber()
Checks if this PdfObject is of the type PdfNumber.
booleanisStream()
Checks if this PdfObject is of the type PdfStream.
booleanisString()
Checks if this PdfObject is of the type PdfString.
intlength()
Returns the length of the actual content of the PdfObject.
protected voidsetContent(String content)
Changes the content of this PdfObject.
voidsetIndRef(PRIndirectReference indRef)
Setter for property indRef.
voidtoPdf(PdfWriter writer, OutputStream os)
Writes the PDF representation of this PdfObject as an array of bytes to the writer.
StringtoString()
Returns the String-representation of this PdfObject.
inttype()
Returns the type of this PdfObject.

Field Detail

ARRAY

public static final int ARRAY
a possible type of PdfObject

bytes

protected byte[] bytes
the content of this PdfObject

BOOLEAN

public static final int BOOLEAN
a possible type of PdfObject

DICTIONARY

public static final int DICTIONARY
a possible type of PdfObject

indRef

protected PRIndirectReference indRef
Holds value of property indRef.

INDIRECT

public static final int INDIRECT
a possible type of PdfObject

NAME

public static final int NAME
a possible type of PdfObject

NOTHING

public static final String NOTHING
This is an empty string used for the PdfNull-object and for an empty PdfString-object.

NULL

public static final int NULL
a possible type of PdfObject

NUMBER

public static final int NUMBER
a possible type of PdfObject

STREAM

public static final int STREAM
a possible type of PdfObject

STRING

public static final int STRING
a possible type of PdfObject

type

protected int type
the type of this PdfObject

TEXT_PDFDOCENCODING

public static final String TEXT_PDFDOCENCODING
This is the default encoding to be used for converting Strings into bytes and vice versa. The default encoding is PdfDocEncoding.

TEXT_UNICODE

public static final String TEXT_UNICODE
This is the encoding to be used to output text in Unicode.

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, 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

canBeInObjStm

public boolean canBeInObjStm()
Can this object be in an object stream?

Returns: true if this object can be in an object stream.

getBytes

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

Returns: a byte array

getIndRef

public PRIndirectReference getIndRef()
Getter for property indRef.

Returns: Value of property indRef.

isArray

public boolean isArray()
Checks if this PdfObject is of the type PdfArray.

Returns: true or false

isBoolean

public boolean isBoolean()
Checks if this PdfObject is of the type PdfBoolean.

Returns: true or false

isDictionary

public boolean isDictionary()
Checks if this PdfObject is of the type PdfDictionary.

Returns: true or false

isIndirect

public boolean isIndirect()
Checks if this is an indirect object.

Returns: true if this is an indirect object

isName

public boolean isName()
Checks if this PdfObject is of the type PdfName.

Returns: true or false

isNull

public boolean isNull()
Checks if this PdfObject is of the type PdfNull.

Returns: true or false

isNumber

public boolean isNumber()
Checks if this PdfObject is of the type PdfNumber.

Returns: true or false

isStream

public boolean isStream()
Checks if this PdfObject is of the type PdfStream.

Returns: true or false

isString

public boolean isString()
Checks if this PdfObject is of the type PdfString.

Returns: true or false

length

public int length()
Returns the length of the actual content of the PdfObject.

In some cases, namely for PdfString and PdfStream, this method differs from the method pdfLength because pdfLength returns the length of the PDF representation of the object, not of the actual content as does the method length.

Remark: the actual content of an object is in some cases identical to its representation. The following statement is always true: length() >= pdfLength().

Returns: a length

setContent

protected void setContent(String content)
Changes the content of this PdfObject.

Parameters: content the new content of this PdfObject

setIndRef

public void setIndRef(PRIndirectReference indRef)
Setter for property indRef.

Parameters: indRef New value of property indRef.

toPdf

public void toPdf(PdfWriter writer, OutputStream os)
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: IOException

toString

public String toString()
Returns the String-representation of this PdfObject.

Returns: a String

type

public int type()
Returns the type of this PdfObject.

Returns: a type