Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

pdf generation - Laravel Snappy: TailwindCSS not loading completely

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.

question from:https://stackoverflow.com/questions/65944326/laravel-snappy-tailwindcss-not-loading-completely

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...