KnpLabs / snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage

Home Page:https://knplabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't load CSS

NicolasSDuoc opened this issue · comments

Hello, im trying to load some custom css and Bootstrap css to an html file, but they don't get loaded, can someone help me with this?

I'm using symfony 5.

Here is the header on the html.twig file:

<link href="{{ absolute_url(asset('css/style.min.css'))}}" rel="stylesheet">
<link href="{{ absolute_url(asset('assets/libs/bootstrap/dist/css/bootstrap.min.css'))}}" rel="stylesheet">

and here is the controller:

$pdf = $this->renderView('guia\pdf.html.twig', ['gdets'=>$gdets,'guia'=>$e_guia,'movmsg'=>$mov_mensaje]);

        $filename = 'test.pdf'
        return new PdfResponse(
            $this->knpSnappyPdf->getOutputFromHtml($pdf),
            $filename
        ); 

i have tried with absolute url, putting http://localhost...bootstrap.css and the cdn link but it doesn't work.

Any help really appreciated :)

Hello,
I suggest you to try to run the wkhtmltopdf command manually (like wkhtmltopdf YOUR_PAGE_URL) and see if, with the verbose option on, you'll get more information.
It's hard to say what's happening here without Symfony + web server logs as, this issue, it can be caused by different causes.

Hello, I have the same problem with laravel. On the other hand, the colors are displayed on my mac. Has anyone found the solution?

Hello, I have the same problem with laravel. On the other hand, the colors are displayed on my mac. Has anyone found the solution?

Hi, i ended up using Bootstrap 3, i read somewhere that flex doesnt work on wkhtmltopdf, so i had to do the document again with bs3, maybe you can try that

It's probably that - wkhtmltopdf is a pretty old rendering engine, newer CSS stuff isn't working.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.