4

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?

eleven0
  • 263
  • 6
  • 13

2 Answers2

3

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" />
Prafulla Kumar Sahu
  • 9,321
  • 11
  • 68
  • 105
  • Neither `` nor `` is working for me in Laravel Snappy :/ Any more ideas? – Pathros May 05 '20 at 23:19
  • 2
    @Pathros try to print ‘{{ asset(“css/app.css”}}’ and you will see the path, it is referring and accordingly you can change. For understanding, ‘assert()’ is you public directory uri. – Prafulla Kumar Sahu May 06 '20 at 02:16
1

(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.

Thushara Buddhika
  • 1,652
  • 12
  • 14