Class PdfArray
- Direct Known Subclasses:
PdfRectangle
PdfArray is the PDF Array object.
An array is a sequence of PDF objects. An array may contain a mixture of object types. An array is written as a left
square bracket ([), followed by a sequence of objects, followed by a right square bracket (]).
This object is
described in the 'Portable Document Format Reference Manual version 1.7' section 3.2.5 (page 58).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionthis is the actual array of PdfObjectsFields inherited from class org.openpdf.text.pdf.PdfObject
ARRAY, BOOLEAN, bytes, DICTIONARY, INDIRECT, NAME, NOTHING, NULL, NUMBER, STREAM, STRING, TEXT_PDFDOCENCODING, TEXT_UNICODE, type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int[] values) Adds an array ofintvalues to end of thePdfArray.booleanAdds aPdfObjectto the end of thePdfArray.booleanChecks if thePdfArrayalready contains a certainPdfObject.getAsName(int idx) Returns aPdfObjectas aPdfName, resolving indirect references.getDirectObject(int idx) Returns thePdfObjectwith the specified index, resolving a possible indirect reference to a direct object.getPdfObject(int idx) Returns thePdfObjectwith the specified index.booleanisEmpty()Returnstrueif the array is empty.intsize()Returns the number of entries in the array.voidtoPdf(PdfWriter writer, OutputStream os) Writes the PDF representation of thisPdfArrayas an array ofbyteto the specifiedOutputStream.toString()Returns a string representation of thisPdfArray.Methods inherited from class org.openpdf.text.pdf.PdfObject
canBeInObjStm, getBytes, isArray, isDictionary, isName, isNull, isNumber, isString, setContent, type
-
Field Details
-
arrayList
this is the actual array of PdfObjects
-
-
Constructor Details
-
PdfArray
public PdfArray()Constructs an emptyPdfArray-object. -
PdfArray
Constructs anPdfArray-object, containing 1PdfObject.- Parameters:
object- aPdfObjectthat has to be added to the array
-
PdfArray
public PdfArray(int[] values) Constructs aPdfArray-object, containing allintvalues in a specified array.The
intvalues are internally converted toPdfNumberobjects.- Parameters:
values- an array ofintvalues to be added
-
PdfArray
Constructs aPdfArray, containing all elements of a specifiedList.- Parameters:
pdfObjectList- anListwithPdfObjects to be added to the array- Since:
- 2.1.3
-
-
Method Details
-
toPdf
Writes the PDF representation of thisPdfArrayas an array ofbyteto the specifiedOutputStream.- Overrides:
toPdfin classPdfObject- Parameters:
writer- for backwards compatibilityos- theOutputStreamto write the bytes to.- Throws:
IOException- on error
-
toString
Returns a string representation of thisPdfArray.The string representation consists of a list of all
PdfObjects contained in thisPdfArray, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). -
size
public int size()Returns the number of entries in the array.- Returns:
- the size of the List
-
isEmpty
public boolean isEmpty()Returnstrueif the array is empty.- Returns:
trueif the array is empty- Since:
- 2.1.5
-
add
Adds aPdfObjectto the end of thePdfArray.The
PdfObjectwill be the last element.- Parameters:
object-PdfObjectto add- Returns:
- always
true
-
add
public boolean add(int[] values) Adds an array ofintvalues to end of thePdfArray.The values will be the last elements. The
intvalues are internally converted toPdfNumberobjects.- Parameters:
values- An array ofintvalues to add- Returns:
- always
true
-
contains
Checks if thePdfArrayalready contains a certainPdfObject.- Parameters:
object- ThePdfObjectto check- Returns:
true
-
getPdfObject
Returns thePdfObjectwith the specified index.A possible indirect references is not resolved, so the returned
PdfObjectmay be either a direct object or an indirect reference, depending on how the object is stored in thePdfArray.- Parameters:
idx- The index of thePdfObjectto be returned- Returns:
- A
PdfObject
-
getDirectObject
Returns thePdfObjectwith the specified index, resolving a possible indirect reference to a direct object.Thus this method will never return a
PdfIndirectReferenceobject.- Parameters:
idx- The index of thePdfObjectto be returned- Returns:
- A direct
PdfObjectornull
-
getAsName
Returns aPdfObjectas aPdfName, resolving indirect references.The object corresponding to the specified index is retrieved and resolved to a direct object. If it is a
PdfName, it is cast down and returned as such. Otherwisenullis returned.- Parameters:
idx- The index of thePdfObjectto be returned- Returns:
- the corresponding
PdfNameobject, ornull
-