Class PdfObject
java.lang.Object
com.aowagie.text.pdf.PdfObject
- Direct Known Subclasses:
PdfArray, PdfBoolean, PdfDictionary, PdfIndirectReference, PdfLiteral, PdfName, PdfNumber, PdfString
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA possible type ofPdfObjectprotected byte[]The content of thisPdfObjectstatic final intA possible type ofPdfObjectstatic final intA possible type ofPdfObjectstatic final StringThis is the encoding to be used to output text in Unicode.protected intThe type of thisPdfObject -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPdfObject(int type) Constructs aPdfObjectof a certain type without any content.protectedPdfObject(int type, byte[] bytes) Constructs aPdfObjectof a certain type with a certain content.protectedConstructs aPdfObjectof a certain type with a certain content. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBytes()Gets the presentation of this object in a byte arrayGet the indirect referencebooleanisArray()Checks if thisPdfObjectis of the typePdfArray.booleanChecks if thisPdfObjectis of the typePdfBoolean.booleanChecks if thisPdfObjectis of the typePdfDictionary.booleanChecks if thisPdfObjectis of the typePdfIndirectObject.booleanisName()Checks if thisPdfObjectis of the typePdfName.booleanisNull()Checks if thisPdfObjectis of the typePdfNull.booleanisNumber()Checks if thisPdfObjectis of the typePdfNumber.booleanisStream()Checks if thisPdfObjectis of the typePdfStream.booleanisString()Checks if thisPdfObjectis of the typePdfString.protected voidsetContent(String content) Changes the content of thisPdfObject.voidsetIndRef(PRIndirectReference indRef) Set the indirect referencevoidtoPdf(PdfWriter writer, OutputStream os) Writes the PDF representation of thisPdfObjectas an array ofbytes to the writer.toString()Returns theString-representation of thisPdfObject.inttype()Returns the type of thisPdfObject.
-
Field Details
-
ARRAY
public static final int ARRAYA possible type ofPdfObject- See Also:
-
STREAM
public static final int STREAMA possible type ofPdfObject- See Also:
-
INDIRECT
public static final int INDIRECTA possible type ofPdfObject- See Also:
-
TEXT_UNICODE
This is the encoding to be used to output text in Unicode.- See Also:
-
bytes
protected byte[] bytesThe content of thisPdfObject -
type
protected int typeThe type of thisPdfObject
-
-
Constructor Details
-
PdfObject
protected PdfObject(int type) Constructs aPdfObjectof a certain type without any content.- Parameters:
type- type of the newPdfObject
-
PdfObject
Constructs aPdfObjectof a certain type with a certain content.- Parameters:
type- type of the newPdfObjectcontent- content of the newPdfObjectas aString.
-
PdfObject
protected PdfObject(int type, byte[] bytes) Constructs aPdfObjectof a certain type with a certain content.- Parameters:
type- type of the newPdfObjectbytes- content of the newPdfObjectas an array ofbyte.
-
-
Method Details
-
toPdf
Writes the PDF representation of thisPdfObjectas an array ofbytes to the writer.- Parameters:
writer- for backwards compatibilityos- TheOutputStreamto write the bytes to.- Throws:
IOException- Exception with a I/O error
-
toString
-
getBytes
public byte[] getBytes()Gets the presentation of this object in a byte array- Returns:
- a byte array
-
setContent
Changes the content of thisPdfObject.- Parameters:
content- the new content of thisPdfObject
-
type
public int type()Returns the type of thisPdfObject. May be either of: - NULL: APdfNull- BOOLEAN: APdfBoolean- NUMBER: APdfNumber- STRING: APdfString- NAME: APdfName- ARRAY: APdfArray- DICTIONARY: APdfDictionary- STREAM: APdfStream- INDIRECT: APdfIndirectObject- Returns:
- The type
-
isNull
public boolean isNull()Checks if thisPdfObjectis of the typePdfNull.- Returns:
trueorfalse
-
isBoolean
public boolean isBoolean()Checks if thisPdfObjectis of the typePdfBoolean.- Returns:
trueorfalse
-
isNumber
public boolean isNumber()Checks if thisPdfObjectis of the typePdfNumber.- Returns:
trueorfalse
-
isString
public boolean isString()Checks if thisPdfObjectis of the typePdfString.- Returns:
trueorfalse
-
isName
public boolean isName()Checks if thisPdfObjectis of the typePdfName.- Returns:
trueorfalse
-
isArray
public boolean isArray()Checks if thisPdfObjectis of the typePdfArray.- Returns:
trueorfalse
-
isDictionary
public boolean isDictionary()Checks if thisPdfObjectis of the typePdfDictionary.- Returns:
trueorfalse
-
isStream
public boolean isStream()Checks if thisPdfObjectis of the typePdfStream.- Returns:
trueorfalse
-
isIndirect
public boolean isIndirect()Checks if thisPdfObjectis of the typePdfIndirectObject.- Returns:
trueif this is an indirect object, otherwisefalse
-
getIndRef
-
setIndRef
Set the indirect reference- Parameters:
indRef- New value as aPdfIndirectReference
-