Class PdfObject
- java.lang.Object
-
- com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfObject
-
- Direct Known Subclasses:
PdfArray,PdfBoolean,PdfDictionary,PdfIndirectReference,PdfLiteral,PdfName,PdfNull,PdfNumber,PdfString
public abstract class PdfObject extends Object
PdfObjectis 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
Fields Modifier and Type Field Description static intARRAYa possible type ofPdfObjectstatic intBOOLEANa possible type ofPdfObjectprotected byte[]bytesthe content of thisPdfObjectstatic intDICTIONARYa possible type ofPdfObjectstatic intINDIRECTa possible type ofPdfObjectprotected PRIndirectReferenceindRefHolds value of property indRef.static intm_NULLa possible type ofPdfObjectstatic intNAMEa possible type ofPdfObjectstatic StringNOTHINGThis is an empty string used for thePdfNull-object and for an emptyPdfString-object.static intNUMBERa possible type ofPdfObjectstatic intSTREAMa possible type ofPdfObjectstatic intSTRINGa possible type ofPdfObjectstatic StringTEXT_PDFDOCENCODINGThis is the default encoding to be used for converting Strings into bytes and vice versa.static StringTEXT_UNICODEThis is the encoding to be used to output text in Unicode.protected inttypethe type of thisPdfObject
-
Constructor Summary
Constructors Modifier Constructor Description protectedPdfObject(int type)Constructs aPdfObjectof a certain type without any content.protectedPdfObject(int type, byte[] bytes)Constructs aPdfObjectof a certain type with a certain content.protectedPdfObject(int type, String content)Constructs aPdfObjectof a certain type with a certain content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanBeInObjStm()Can this object be in an object stream?byte[]getBytes()Gets the presentation of this object in a byte arrayPRIndirectReferencegetIndRef()Getter for property indRef.booleanisArray()Checks if thisPdfObjectis of the typePdfArray.booleanisBoolean()Checks if thisPdfObjectis of the typePdfBoolean.booleanisDictionary()Checks if thisPdfObjectis of the typePdfDictionary.booleanisIndirect()Checks if this is an indirect object.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.intlength()Returns the length of the actual content of thePdfObject.protected voidsetContent(String content)Changes the content of thisPdfObject.voidsetIndRef(PRIndirectReference indRef)Setter for property indRef.voidtoPdf(PdfWriter writer, OutputStream os)Writes the PDF representation of thisPdfObjectas an array ofbytes to the writer.StringtoString()Returns theString-representation of thisPdfObject.inttype()Returns the type of thisPdfObject.
-
-
-
Field Detail
-
BOOLEAN
public static final int BOOLEAN
a possible type ofPdfObject- See Also:
- Constant Field Values
-
NUMBER
public static final int NUMBER
a possible type ofPdfObject- See Also:
- Constant Field Values
-
STRING
public static final int STRING
a possible type ofPdfObject- See Also:
- Constant Field Values
-
NAME
public static final int NAME
a possible type ofPdfObject- See Also:
- Constant Field Values
-
ARRAY
public static final int ARRAY
a possible type ofPdfObject- See Also:
- Constant Field Values
-
DICTIONARY
public static final int DICTIONARY
a possible type ofPdfObject- See Also:
- Constant Field Values
-
STREAM
public static final int STREAM
a possible type ofPdfObject- See Also:
- Constant Field Values
-
m_NULL
public static final int m_NULL
a possible type ofPdfObject- See Also:
- Constant Field Values
-
INDIRECT
public static final int INDIRECT
a possible type ofPdfObject- See Also:
- Constant Field Values
-
NOTHING
public static final String NOTHING
This is an empty string used for thePdfNull-object and for an emptyPdfString-object.- See Also:
- Constant Field Values
-
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.- See Also:
- Constant Field Values
-
TEXT_UNICODE
public static final String TEXT_UNICODE
This is the encoding to be used to output text in Unicode.- See Also:
- Constant Field Values
-
bytes
protected byte[] bytes
the content of thisPdfObject
-
type
protected int type
the type of thisPdfObject
-
indRef
protected PRIndirectReference indRef
Holds value of property indRef.
-
-
Constructor Detail
-
PdfObject
protected PdfObject(int type)
Constructs aPdfObjectof a certain type without any content.- Parameters:
type- type of the newPdfObject
-
PdfObject
protected PdfObject(int type, String content)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 Detail
-
toPdf
public void toPdf(PdfWriter writer, OutputStream os) throws IOException
Writes the PDF representation of thisPdfObjectas an array ofbytes to the writer.- Parameters:
writer- for backwards compatibilityos- the outputstream to write the bytes to.- Throws:
IOException
-
getBytes
public byte[] getBytes()
Gets the presentation of this object in a byte array- Returns:
- a byte array
-
canBeInObjStm
public boolean canBeInObjStm()
Can this object be in an object stream?- Returns:
- true if this object can be in an object stream.
-
toString
public String toString()
Returns theString-representation of thisPdfObject.
-
length
public int length()
Returns the length of the actual content of thePdfObject.In some cases, namely for
PdfStringandPdfStream, this method differs from the methodpdfLengthbecausepdfLengthreturns the length of the PDF representation of the object, not of the actual content as does the methodlength.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 thisPdfObject.- Parameters:
content- the new content of thisPdfObject
-
type
public int type()
Returns the type of thisPdfObject.- Returns:
- a 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 this is an indirect object.- Returns:
- true if this is an indirect object
-
getIndRef
public PRIndirectReference getIndRef()
Getter for property indRef.- Returns:
- Value of property indRef.
-
setIndRef
public void setIndRef(PRIndirectReference indRef)
Setter for property indRef.- Parameters:
indRef- New value of property indRef.
-
-