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

Error while inserting a random PDF to another PDF #61

Open
Vishalj32 opened this issue Jul 11, 2023 · 2 comments
Open

Error while inserting a random PDF to another PDF #61

Vishalj32 opened this issue Jul 11, 2023 · 2 comments

Comments

@Vishalj32
Copy link

I am getting a nil pointer error on resolveObjects method while I am inserting an existing pdf to a new pdf

package main

import "github.com/signintech/gopdf"

func main() {
	gPdf := gopdf.GoPdf{}
	gPdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4}) //595.28, 841.89 = A4

	pdf := gPdf.ImportPage("/tmp/documents/agreement.pdf", 1, "/MediaBox")
	gPdf.UseImportedTemplate(pdf, 0, 0, 150, 0)

	_ = gPdf.WritePdf("/tmp/documents/see-all.pdf")
}

StackTrace:

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

goroutine 1 [running]:
github.com/phpdave11/gofpdi.(*PdfReader).resolveObject(0x140000b4210, 0x0)
        /Users/vishaljain/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.14-0.20211212211723-1f10f9844311/reader.go:599 +0x13c
github.com/phpdave11/gofpdi.(*PdfReader).readPages(0x140000b4210)
        /Users/vishaljain/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.14-0.20211212211723-1f10f9844311/reader.go:1228 +0x4c
github.com/phpdave11/gofpdi.(*PdfReader).read(0x140000b4210)
        /Users/vishaljain/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.14-0.20211212211723-1f10f9844311/reader.go:1622 +0x4c
github.com/phpdave11/gofpdi.(*PdfReader).init(0x140000b4210)
        /Users/vishaljain/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.14-0.20211212211723-1f10f9844311/reader.go:75 +0x11c
github.com/phpdave11/gofpdi.NewPdfReader({0x1003f9d75, 0x3d})
        /Users/vishaljain/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.14-0.20211212211723-1f10f9844311/reader.go:61 +0xc4
github.com/phpdave11/gofpdi.(*Importer).SetSourceFile(0x1400009e040, {0x1003f9d75?, 0x5000?})
        /Users/vishaljain/go/pkg/mod/github.com/phpdave11/gofpdi@v1.0.14-0.20211212211723-1f10f9844311/importer.go:69 +0x80
github.com/signintech/gopdf.(*GoPdf).ImportPage(0x140000cc000, {0x1003f9d75?, 0x0?}, 0x0?, {0x1003f0cbc, 0x9})
        /Users/vishaljain/go/pkg/mod/github.com/signintech/gopdf@v0.18.0/gopdf.go:1387 +0x40
main.main()
        /Users/vishaljain/go/src/pdftester/main.go:9 +0xcc
exit status 2

If we can add a nil check on the method it would be really helpful, on this specific file

@Brindrajsinh-Chauhan
Copy link

Facing the same issue. An solutions?

@0x-1
Copy link

0x-1 commented Apr 2, 2024

seems to be fixed by this code in a fork:
7591c1f
https://github.com/happyreturns/gofpdi

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