innoveit / play2-pdf

A PDF module for Play Framework 2
MIT License
77 stars 22 forks source link

Problem with image rendering #28

Closed Omnia89 closed 6 years ago

Omnia89 commented 6 years ago

Hello, i'm having some problems rendering a logo in a pdf.

In the scala template I've tried to load it both with @routes.Assets.at() and @routes.Assets.versioned(). If I render normally the template, the image shows up, when I use return pdfGenerator.ok(PDFList.render(courseSession), request().host());, no image. The image is a simple .png file.

I'm using Play Framework 2.5 and play2-pdf 1.6.0 version (firstly tried with 1.7, but didn't worked)

marcosinigaglia commented 6 years ago

Hi, try to use an absolute path for the image, the request host is correct?

Omnia89 commented 6 years ago

Yes, the request host return the correct url.

I've tried those things:

Here i had the doubt that my file had something wrong, so I recreated the logo in .gif and:

So I ended making a little function that recreates the absolute url for the assets that I'm gonna use in the pdf.

Thanks for the tip, was the only thing I didn't tested!