Minor fix to allow null for colorspace entry in Resource dicts

This commit is contained in:
Gunnsteinn Hall 2017-04-26 23:23:29 +00:00
parent 3f4e84a2e4
commit 78c6f01d03
2 changed files with 9 additions and 1 deletions

View File

@ -40,7 +40,7 @@ func NewPdfPageResourcesFromDict(dict *PdfObjectDictionary) (*PdfPageResources,
if obj, isDefined := (*dict)["ExtGState"]; isDefined {
r.ExtGState = obj
}
if obj, isDefined := (*dict)["ColorSpace"]; isDefined {
if obj, isDefined := (*dict)["ColorSpace"]; isDefined && !isNullObject(obj) {
colorspaces, err := newPdfPageResourcesColorspacesFromPdfObject(obj)
if err != nil {
return nil, err

View File

@ -28,6 +28,14 @@ func getNumberAsFloat(obj PdfObject) (float64, error) {
return 0, errors.New("Not a number")
}
func isNullObject(obj PdfObject) bool {
if _, isNull := obj.(*PdfObjectNull); isNull {
return true
} else {
return false
}
}
// Convert a list of pdf objects representing floats or integers to a slice of float64 values.
func getNumbersAsFloat(objects []PdfObject) ([]float64, error) {
floats := []float64{}