API Documentation for Array
NoPoDoFo Array
An array object is a one dimensional heterogeneous collection of Object(s). PDF directly supports one dimensional arrays, however arrays of greater dimension are possible by constructing arrays as elements of arrays; nested array. NoPoDoFo does not currently support the creation of new PDf Array objects. NoPoDoFo Array's are constructed from a NoPoDoFo Object.
class Array {
dirty: boolean
readonly length: number
immutable: boolean
new(): Array
at(i: number): Ref | Object
pop(): Object
clear(index?: number): void
push(v: Object): void
shift(): nopodofo.Object
unshift(v: nopodofo.Object): void
write(destination: string): void
asArray(): any[]
}
Constructor
A new pdf array can be instantiated with the nopodof array constructor. This is an empty array, and does not belong to any document. It is the creators responsibility to assign the array to the document.
new(): Array
Properties
dirty
This flag is internally by PoDoFo, dirty is set to true if there has been a modification after construction.
length
This is a readonly property returning the current size of the array.
immutable
This property will get or set a corresponding property on the PoDoFo PdfArray. When set to true no keys can be edited or changed.
Methods
at
at(i: number): Ref | Object
The [at] method will return the Object or Ref (indirect object reference) at the index provided as the first parameter. If the index is less than zero or greater than the array length a Range Error will be thrown.
pop
pop(): Object
This method will act the same as the native javascript array pop method. Pop will remove and return the last item of an array.
clear
clear(index?: number): void
If an index is provided, only the item at that index will be removed else all object in the array are removed.
push
push(v: Object): void
Add an Object to the end of the array.
shift
shift(): nopodofo.Object | nopodofo.Ref
Get the first element from the array
unshift
unshift(v: nopodofo.Object): void
Push an element to the front of an array, all preceding elements are shifted back
write
write(destination: string): void
Write the array to the destination provided as the first parameter. This destination must be a valid location on disk.
asArray
asArray(): any[]
Convert the PDF Array into a javascript array. This is a readonly array in context, the resulting array will not persist any changes back to the original PDF Array. The use of the method is best for simply viewing the contents of an array in a familiar environment(Javaascript).