phantom-pdf icon indicating copy to clipboard operation
phantom-pdf copied to clipboard

CSS not loading over https

Open tasosback opened this issue 2 years ago • 7 comments

I have a laravel 5 site that was running in http but since they turned it to Https the css is not loading. The view produced is ok as i can see but the pdf does not have any styling (probably the css is not loaded). I see some previous issues that were solved. Where do i add the --ignore-ssl-errors=true setting?

tasosback avatar Dec 23 '22 21:12 tasosback

Publish the config file by running php artisan vendor:publish In the published config file, uncomment this line https://github.com/danielboendergaard/phantom-pdf/blob/master/src/config/config.php#L77

danielboendergaard avatar Dec 24 '22 11:12 danielboendergaard

First of all thanks for the reply. I already changed the published config file "app/config/packages/danielboendergaard/phantom-pdf/config.php" and commented out the line you specified but it did not work. If I run php artisan vendor:publish will it affect other packages as well? is it necessary to run it if I already changed the published config file?

tasosback avatar Dec 26 '22 20:12 tasosback

Actually I made a simple test without https and still the css styling is ignored. Only inline styles work. Can this be a version issue? What version do you recommend for Laravel 5?

tasosback avatar Dec 27 '22 09:12 tasosback

Try setting the base_url here: https://github.com/danielboendergaard/phantom-pdf/blob/master/src/config/config.php#L27

danielboendergaard avatar Dec 27 '22 10:12 danielboendergaard

Changed the base url but it did not work. Also tried a very simple css file in HTTP and still the css file is ignored although i see it in the produced html file.

tasosback avatar Dec 28 '22 20:12 tasosback

Any other ideas? Does the library support css files at all?

tasosback avatar Jan 02 '23 20:01 tasosback

The url used in the link tag must be reachable from the host machine itself. This can cause dns and https issues. It's probably easier to inline the css.

Alternatively I would take a look at one of these options: https://packagist.org/packages/barryvdh/laravel-dompdf https://packagist.org/packages/spatie/browsershot

danielboendergaard avatar Jan 03 '23 10:01 danielboendergaard