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).
PdfNull,
PdfBoolean,
PdfNumber,
PdfString,
PdfName,
PdfArray,
PdfDictionary,
PdfStream,
PdfIndirectReference| Modifier and Type | Field and Description |
|---|---|
static int |
ARRAY
A possible type of
PdfObject |
protected byte[] |
bytes
The content of this
PdfObject |
static int |
INDIRECT
A possible type of
PdfObject |
static int |
STREAM
A possible type of
PdfObject |
static String |
TEXT_UNICODE
This is the encoding to be used to output text in Unicode.
|
protected int |
type
The type of this
PdfObject |
| Modifier | Constructor and 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,
String content)
Constructs a
PdfObject of a certain type
with a certain content. |
| Modifier and Type | Method and Description |
|---|---|
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(String content)
Changes the content of this
PdfObject. |
void |
setIndRef(PRIndirectReference indRef)
Set the indirect reference
|
void |
toPdf(PdfWriter writer,
OutputStream os)
Writes the PDF representation of this
PdfObject as an
array of bytes to the writer. |
String |
toString()
Returns the
String-representation of this
PdfObject. |
int |
type()
Returns the type of this
PdfObject. |
public static final int ARRAY
PdfObjectpublic static final int STREAM
PdfObjectpublic static final int INDIRECT
PdfObjectpublic static final String TEXT_UNICODE
protected byte[] bytes
PdfObjectprotected int type
PdfObjectprotected PdfObject(int type)
PdfObject of a certain type
without any content.type - type of the new PdfObjectprotected PdfObject(int type,
String content)
PdfObject of a certain type
with a certain content.type - type of the new PdfObjectcontent - content of the new PdfObject as a
String.protected PdfObject(int type,
byte[] bytes)
PdfObject of a certain type
with a certain content.type - type of the new PdfObjectbytes - content of the new PdfObject as an array of
byte.public void toPdf(PdfWriter writer, OutputStream os) throws IOException
PdfObject as an
array of bytes to the writer.writer - for backwards compatibilityos - The OutputStream to write the bytes to.IOException - Exception with a I/O errorpublic String toString()
String-representation of this
PdfObject.public byte[] getBytes()
protected void setContent(String content)
PdfObject.content - the new content of this PdfObjectpublic int type()
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 PdfIndirectObjectpublic boolean isNull()
PdfObject is of the type
PdfNull.true or falsepublic boolean isBoolean()
PdfObject is of the type
PdfBoolean.true or falsepublic boolean isNumber()
PdfObject is of the type
PdfNumber.true or falsepublic boolean isString()
PdfObject is of the type
PdfString.true or falsepublic boolean isName()
PdfObject is of the type
PdfName.true or falsepublic boolean isArray()
PdfObject is of the type
PdfArray.true or falsepublic boolean isDictionary()
PdfObject is of the type
PdfDictionary.true or falsepublic boolean isStream()
PdfObject is of the type
PdfStream.true or falsepublic boolean isIndirect()
PdfObject is of the type
PdfIndirectObject.true if this is an indirect object,
otherwise falsepublic PRIndirectReference getIndRef()
PdfIndirectReferencepublic void setIndRef(PRIndirectReference indRef)
indRef - New value as a PdfIndirectReferenceCopyright © 2021. All rights reserved.