innoveit / play2-pdf

A PDF module for Play Framework 2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with image rendering

Omnia89 opened this issue · comments

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)

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

Yes, the request host return the correct url.

I've tried those things:

  • random internet image with direct url: worked
  • my .png with relative and direct url: not working
  • my .png loaded to a server: not working

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

  • with Assets.versioned and Assets.at: not working
  • direct url: worked

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!