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

Unable to import PDF exported from browsers (Chromium/Firefox/Blink/Gecko) #49

Open
vqvw opened this issue Jan 20, 2022 · 1 comment
Open

Comments

@vqvw
Copy link

vqvw commented Jan 20, 2022

Hello, this package is great, but I'm unable to import PDFs that have been exported from browsers.

It works completely fine when importing PDFs exported from jung-kurt/gofpdf, but if I try to import a PDF exported from Chromium or Firefox I get the following error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51831b]

goroutine 1 [running]:
github.com/phpdave11/gofpdi.(*PdfReader).resolveObject(0xc00010c4d0, 0x0)
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/reader.go:599 +0x19b
github.com/phpdave11/gofpdi.(*PdfReader).readPages(0xc00010c4d0)
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/reader.go:1228 +0x52
github.com/phpdave11/gofpdi.(*PdfReader).read(0xc00010c4d0)
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/reader.go:1622 +0x5e
github.com/phpdave11/gofpdi.(*PdfReader).init(0xc00010c4d0)
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/reader.go:75 +0x105
github.com/phpdave11/gofpdi.NewPdfReader({0x55f1ff, 0xc000016390})
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/reader.go:61 +0xdc
github.com/phpdave11/gofpdi.(*Importer).SetSourceFile(0xc00002b580, {0x55f1ff, 0x0})
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/importer.go:67 +0x6a
github.com/phpdave11/gofpdf/contrib/gofpdi.(*Importer).ImportPage(0xc00000e5b0, {0x597b58, 0xc000142000}, {0x55f1ff, 0x55d01b}, 0x2, {0x55e516, 0x9})
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/contrib/gofpdi/gofpdi.go:43 +0x4b
github.com/phpdave11/gofpdf/contrib/gofpdi.ImportPage(...)
        /mnt/Portable/Programming/Go/pkg/mod/github.com/phpdave11/[email protected]/contrib/gofpdi/gofpdi.go:115
main.main()
        /mnt/Portable/Programming/Go/src/github.com/barjoio/pdf-header-footer/main.go:14 +0x116
exit status 2

gofpdi version: v1.4.2

@anibaldeboni
Copy link

Got the same error when importing a pdf generated with iText. Would be better if the function returned an error instead of panicking

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

2 participants