yala ramesh
yala ramesh

Reputation: 3362

How to use image Url in gofpdf

i am using golang in service side, i am create a pdf using gofpdf , i need to show image on the top of the pdf page, in gofpdf documentation they provide a methods for this ImageOptions(), Image() i have image link URL i will do like below but it's not working ,got error file not found.

ImageOptions(https://cdn.recast.ai/newsletter/city-01.png, 10, 10, 30, 
 0, false, "", 0, "")

And

Image(https://cdn.recast.ai/newsletter/city-01.png,10, 10, 30, 0, false, "", 0, "")

Above both are not working,Any one help me how to show image using image Url. Thanks.

Upvotes: 2

Views: 2643

Answers (1)

yala ramesh
yala ramesh

Reputation: 3362

i got a solution for this it's woks me, if you want to show image on your pdf , first you need to register your image (it do inside http.get() call to your image), I hope this below link is useful.

url := "https://cdn.recast.ai/newsletter/city-01.png"
httpimg.Register(pdf, url, "")
pdf.Image(url, 15, 15, 267, 0, false, "", 0, "") 

Reference link: https://godoc.org/github.com/jung-kurt/gofpdf/contrib/httpimg

Upvotes: 1

Related Questions