Laravel Snappy: TailwindCSS not loading completely

梦想与她 提交于 2021-02-11 12:26:40

问题


I am using Laravel (8 Jetstream) Snappy to print quite a colorful PDF from a blade view with TailwindCSS v2.

However, the blade view is not the same looking in the generated PDF.

First of all, nothing worked if I had the following call to the CSS file:

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

So I changed asset() for public_path(). Here is the whole blade view:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>PDF generated</title>
    <link href="{{ public_path('css/app.css') }}" rel="stylesheet" media="all" />
</head>
<body>

<div class="container mx-auto px-4 py-4">
    <div class="border-4 border-red-400">
        <div class="text-green-800">
            Text in color.
        </div>
    </div>
</div>

</body>
</html>

The problem is that I just see a black and white version. The colors are not loading.

Also, the following is not working either:

<link href="{{ public_path('css/app.css') }}" rel="stylesheet" type="text/css" />

What am I missing? How do I get this fixed? I want to Tailwind to work as well in the PDF printed version.

来源:https://stackoverflow.com/questions/65944326/laravel-snappy-tailwindcss-not-loading-completely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!