简体   繁体   中英

dompdf dont load bootstrap css with barryvdh/laravel-dompdf

i use barryvdh\/laravel-dompdf in laravel 5.5 and bootstrap css (renamed to pdf.css with small adjustments) to generate a report in pdf this is my header from the report view calling the css:

<!DOCTYPE html>
 <html lang="en">
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  
     <link href="{{public_path('css/pdf.css') }}" rel="stylesheet" type="text/css" />            
</head>
<body>   

您必须将所有 css 文件放在 style 标签中才能启动您的代码

barryvdh/laravel-dompdf does not support boostrap yet.

Quoting the author:

I highly doubt that DomPDF can handle Bootstrap correctly. If you need better pdf, try: https://github.com/barryvdh/laravel-snappy That used Webkit to render pdf.

See more about the issue here

Change your file path to this, if CSS and images are not inside the public directory.

<img src="{{ base_path().'/location/to/image/image.png' }}" />
<link rel="stylesheet" type="text/css" href="{{ base_path().'/location/css/bootstrap.min.css' }}">

You should use another version of bootstrap. because i tested it with bootstrap 3 and it's not working but it works with version 4 of the framework.

我遇到了同样的问题,我所做的就是创建另一个刀片文件,将 bootstrap.css 内容复制到其中(在样式标签之间),然后将它(带有 css 的文件)包含在我想打印的文件中

gus please i am currently in this mess, i have tried it all , it wount style at all, i have a payslip , it looks nice locally, but when i test it on production it takes out the whole styles, please any fix for this bug? thanks in adavnce

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM