mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-27 13:48:51 +08:00
21 lines
431 B
Go
21 lines
431 B
Go
![]() |
package extractor
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
|
||
|
"github.com/unidoc/unidoc/pdf/core"
|
||
|
)
|
||
|
|
||
|
// getNumberAsFloat can retrieve numeric values from PdfObject (both integer/float).
|
||
|
func getNumberAsFloat(obj core.PdfObject) (float64, error) {
|
||
|
if fObj, ok := obj.(*core.PdfObjectFloat); ok {
|
||
|
return float64(*fObj), nil
|
||
|
}
|
||
|
|
||
|
if iObj, ok := obj.(*core.PdfObjectInteger); ok {
|
||
|
return float64(*iObj), nil
|
||
|
}
|
||
|
|
||
|
return 0, errors.New("Not a number")
|
||
|
}
|