innoveit / play2-pdf

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

.css styles ignored #11

Closed immortalcy closed 8 years ago

immortalcy commented 8 years ago

Hello and thanks for the great module.

I am trying to attach a .pdf file to an email by using val pdf = pdfGenerator.toBytes(pdf.render(object), "http://localhost:9000/") and it seems like the .css files are ignored; something that is not happening when I include an image to it (both included with @routes.Assets.public("file.ext")).

Generated .pdf contains all the images (as it should) but there is no style applies to it.

Maybe this might be related to this issue?

marcosinigaglia commented 8 years ago

Hi, which version are you using? Can you paste some example code?

immortalcy commented 8 years ago

Yes sorry.

Version: "it.innove" % "play2-pdf" % "1.4.0"

Examples Code:

<html>
    <head>
        <title>PDF Sample</title>
        <meta charset="UTF-8">

        <link rel="stylesheet" type="text/css" href="@routes.Assets.public("pdf/main.css")">
        <link rel="stylesheet" type="text/css" href="@routes.Assets.public("pdf/bootstrap/css/bootstrap.min.css")">
        <link rel="stylesheet" type="text/css" href="@routes.Assets.public("pdf/bootstrap/css/bootstrap-theme.min.css")">
    </head>
    <body>

<div class="container">
    <div class="row">
        <div class="col-xs-12">
        </div>
    </div>
</div>

</body>
</html>
immortalcy commented 8 years ago

Hmmm, I dont know if it really matters but this code is based on the scala multiseed project from here.

marcosinigaglia commented 8 years ago

I don't know the project, maybe the problem is the relative path of the css resources, can you try to use absolute path?

immortalcy commented 8 years ago

Yes but if that was the case wouldn't the page render have the same issue as well? I mean displayed without the styles?

marcosinigaglia commented 8 years ago

I can't get your point, can you explain better? I don't know how the multidomain project handles the static resources. The HTML request is made outside the user session so maybe there are some problems in there.

immortalcy commented 8 years ago

And it is able to find all the images but not the .css? That is the most strange thing that happens.

marcosinigaglia commented 8 years ago

The images are from the same routes? Try add this in your routes: GET /pdf/*file controllers.Assets.at(path="/public/pdf", file)

immortalcy commented 8 years ago

Yes the images are exactly on the same location with main.css I will try it and let you know.

immortalcy commented 8 years ago

The .css file is included as well. I am not sure if its something we changed on the routes of the multipart project or not but now it works!!

Thanks for your time and help.

marcosinigaglia commented 8 years ago

You're welcome