mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-02 22:17:06 +08:00
Add Len and Get methods to PdfObjectArray
This commit is contained in:
parent
bf57d9d5a0
commit
4548fd56a5
@ -330,6 +330,22 @@ func (array *PdfObjectArray) Append(obj PdfObject) {
|
||||
*array = append(*array, obj)
|
||||
}
|
||||
|
||||
// Len returns the number of elements in the array.
|
||||
func (array *PdfObjectArray) Len() int {
|
||||
if array == nil {
|
||||
return 0
|
||||
}
|
||||
return len(*array)
|
||||
}
|
||||
|
||||
// Get returns the i-th element of the array or nil if out of bounds.
|
||||
func (array *PdfObjectArray) Get(i int) PdfObject {
|
||||
if array == nil || i >= len(*array) || i < 0 {
|
||||
return nil
|
||||
}
|
||||
return (*array)[i]
|
||||
}
|
||||
|
||||
func getNumberAsFloat(obj PdfObject) (float64, error) {
|
||||
if fObj, ok := obj.(*PdfObjectFloat); ok {
|
||||
return float64(*fObj), nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user