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

slice out of bound #4

Open
afzalabbasi opened this issue Mar 9, 2021 · 2 comments
Open

slice out of bound #4

afzalabbasi opened this issue Mar 9, 2021 · 2 comments

Comments

@afzalabbasi
Copy link

c := wkhtmltoimage.ImageOptions{BinaryPath: "-",Input: "/templates/email.gohtml", Format: "png"}
out, err := wkhtmltoimage.GenerateImage(&c)
if err!=nil{
fmt.Println(err.Error())
}
f, _ := os.Create("/templates/example.png")
defer f.Close()
n2, _ := f.Write(out)
fmt.Printf("wrote %d bytes\n", n2)
i got slice out of bound error can someone please me help me why i got this

@rajkumarairlift
Copy link

i also get some error

html := "

example

"
// BinaryPath:"/usr/local/bin/wkhtmltoimage"
c := wkhtmltoimage.ImageOptions{Input:"-", Format: "png", Output: "example.png", Html: html,BinaryPath:"/usr/local/bin/wkhtmltoimage"}
k,err:=wkhtmltoimage.GenerateImage(&c)
if err!=nil{
fmt.Println(err)
}
fmt.Println(k)

@yusrenaltair
Copy link

yusrenaltair commented Jun 8, 2022

Edited:
Turns Out in GenerateImage function line 68
output, err := cmd.CombinedOutput()
return empty byte slice
So trimmed := cleanupOutput(output, options.Format)
will produce unhandled error
I make a little modification

//.....
output, err := cmd.CombinedOutput()
if err != nil {
  return nil, err
}

if len(output) > 0 {
  trimmed := cleanupOutput(output, options.Format)
  return trimmed, nil
}
return nil, nil
//....

My Specs : Ubuntu 20.3, wktmltopdf wkhtmltox_0.12.6-1.focal_amd64.deb; Go v1.18.3

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