eleven0
eleven0

Reputation: 363

Laravel snappy - How to Load internal/external css

I am trying to get the css styling working for my pdf documents. So far no such luck.

  1. Is it possible to use CDN style sheet documents? When I add say bootstrap stylesheet cdn to my view's head section, I get the error below;

    The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% [======> ] 11% Error: Failed to load https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css, with network status code 3 and http status code 0 - Host not found

  2. I tried adding the entire bootstrap file inline, in that case, there is no error but it seems flexbox is not working at all. Only styling of text properties (font background color etc) changed.

What am I missing here? Ideally, I use tailwindcss on my app, Is it possible for me to use that? If so, How could I do that?

Upvotes: 4

Views: 5358

Answers (2)

Thushara Buddhika
Thushara Buddhika

Reputation: 1820

(Laravel - Lumen)

helpers.php got paths : resource_path(), database_path(), base_path(), storage_path().

Use resource path where the blade files also included. (easy to manage)

<link rel="stylesheet" href="{{ resource_path('views/pdf/invoice/css/styles.css') }}" media="all" />

This will link styles.css file in the resource/views/pdf/invoice/css/ folder path.

Upvotes: 1

Prafulla Kumar Sahu
Prafulla Kumar Sahu

Reputation: 9693

You need to give directory path instead of url path for external css, so if your css file is in public/css directory path

instead of using

<link rel="stylesheet" href="{{ asset('css\style.css') }}" media="all" />

you need to use

<link rel="stylesheet" href="{{ public_path('css\style.css') }}" media="all" />

Upvotes: 3

Related Questions