gen2brain / go-fitz

Golang wrapper for the MuPDF Fitz library
GNU Affero General Public License v3.0
369 stars 87 forks source link

not enough data to determine image format #72

Closed helios741 closed 1 year ago

helios741 commented 1 year ago

Hello, I am very happy to use this lib, but today I meet a problem for some special pdf, which has follow:

error: not enough data to determine image format
error: aborting process from uncaught error!

i use this demo:

func TestA(t *testing.T) {
    doc, err := fitz.New("aaa.pdf")
    if err != nil {
        t.Error(err)
        return
    }
    img, err := doc.Image(0)
    if err != nil {
        panic(err)
    }

    f, err := os.Create("aaa.png")
    if err != nil {
        panic(err)
    }

    err = jpeg.Encode(f, img, &jpeg.Options{jpeg.DefaultQuality})
    if err != nil {
        panic(err)
    }

    f.Close()
}

aaa.pdf link

I find that C.fz_run_page occur error.

please how to fix it.

gen2brain commented 1 year ago

Is this related to https://github.com/gen2brain/go-fitz/issues/57, what do you think should be fixed? If mupdf cannot parse the file, that is it, unless it is related to 57.

gen2brain commented 1 year ago

Looks like it is related to #57 but not confirmed. Reopen if that is not the case.

gen2brain commented 1 year ago

This should be fixed in https://github.com/gen2brain/go-fitz/commit/f15918d712b55047e829b1fe6ce0b46651ca0e40.