Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting crash for some pdf format #100

Closed
helios741 opened this issue Dec 19, 2023 · 2 comments
Closed

getting crash for some pdf format #100

helios741 opened this issue Dec 19, 2023 · 2 comments

Comments

@helios741
Copy link

dxatf_7194703270eb7fa37dc11189ef47dcdb.pdf

This is a pdf document. I want to convert it to image by the following code, But get crash:

warning: ... repeated 33 times...
error: aborting process from uncaught error!

my code to reappear:

package main

import (
	"fmt"
	"image/png"
	"os"
	"path/filepath"

	"github.com/gen2brain/go-fitz"
)

func main() {
	filePath := "document file path"
	doc, err := fitz.New(filePath)
	if err != nil {
		panic(err)
	}

	for i := 0; i < doc.NumPage(); i++ {
		img, err := doc.Image(i)
		localFile := filepath.Join("./", fmt.Sprintf("%d.png", i))
		f, err := os.Create(localFile)
		if err != nil {
			panic(err)
		}
		if err := png.Encode(f, img); err != nil {
			panic(err)
		}
		fmt.Println(localFile)
	}
}

please, How i solve it?

@andikaraditya1
Copy link

@helios741 have you found the fix? I'm also having the same problem

@gen2brain
Copy link
Owner

Now it will return error for broken files when load/run page is started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants