phpdave11 / gofpdi

Go Free PDF Document Importer
MIT License
118 stars 59 forks source link

zlib.NewReader(bytes.NewBuffer(stream)) can return an error and a nil value #41

Open volker-schukai opened 3 years ago

volker-schukai commented 3 years ago

I have a pdf where the encoding does not seem to be supported, but I think you should check the error here, otherwise I get a runtime error.

runtime error: invalid memory address or nil pointer dereference

https://github.com/phpdave11/gofpdi/blob/cf771f66a372da8380cb6c9fe5d9d40133dcc563/reader.go#L509

johan-lejdung commented 1 year ago

I'm running into the same issue, it's assuming zlib can de-compress it and is returning

// ErrHeader is returned when reading ZLIB data that has an invalid header.
ErrHeader = errors.New("zlib: invalid header")

I fixed it in my fork https://github.com/chaintraced/gofpdi/pull/1, but haven't opened a PR here yet since my previous one is still dangling. https://github.com/phpdave11/gofpdi/pull/60