Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...