mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +08:00
Add ToInt64Slice convenience function to PdfObjectArray
This commit is contained in:
parent
0603c51f75
commit
d1f2f280aa
@ -400,7 +400,23 @@ func (array *PdfObjectArray) ToIntegerArray() ([]int, error) {
|
||||
if number, is := obj.(*PdfObjectInteger); is {
|
||||
vals = append(vals, int(*number))
|
||||
} else {
|
||||
return nil, fmt.Errorf("Type error")
|
||||
return nil, ErrTypeError
|
||||
}
|
||||
}
|
||||
|
||||
return vals, nil
|
||||
}
|
||||
|
||||
// ToInt64Slice returns a slice of all array elements as an int64 slice. An error is returned if the
|
||||
// array non-integer objects. Each element can only be PdfObjectInteger.
|
||||
func (array *PdfObjectArray) ToInt64Slice() ([]int64, error) {
|
||||
vals := []int{}
|
||||
|
||||
for _, obj := range array.Elements() {
|
||||
if number, is := obj.(*PdfObjectInteger); is {
|
||||
vals = append(vals, int64(*number))
|
||||
} else {
|
||||
return nil, ErrTypeError
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,11 +580,6 @@ func (d *PdfObjectDictionary) Set(key PdfObjectName, val PdfObject) {
|
||||
|
||||
// Get returns the PdfObject corresponding to the specified key.
|
||||
// Returns a nil value if the key is not set.
|
||||
//
|
||||
// The design is such that we only return 1 value.
|
||||
// The reason is that, it will be easy to do type casts such as
|
||||
// name, ok := dict.Get("mykey").(*PdfObjectName)
|
||||
// if !ok ....
|
||||
func (d *PdfObjectDictionary) Get(key PdfObjectName) PdfObject {
|
||||
val, has := d.dict[key]
|
||||
if !has {
|
||||
|
@ -8,7 +8,7 @@ package model
|
||||
import "github.com/unidoc/unidoc/pdf/core"
|
||||
|
||||
// PdfSignature represents a PDF signature dictionary and is used for signing via form signature fields.
|
||||
// (Section 12.8, Table 252 - Entries in a signature dictionary p. 475).
|
||||
// (Section 12.8, Table 252 - Entries in a signature dictionary p. 475 in PDF32000_2008).
|
||||
type PdfSignature struct {
|
||||
container *core.PdfIndirectObject
|
||||
// Type: Sig
|
||||
|
Loading…
x
Reference in New Issue
Block a user