barryvdh / laravel-snappy

Laravel Snappy PDF
MIT License
2.59k stars 289 forks source link

When running on Windows using the built-in PHP web server, external links such as images or CSS stylesheets do not load. #506

Open vahiddabbagh opened 1 year ago

vahiddabbagh commented 1 year ago

Hi,

This issue only occurs when running Laravel under the built-in PHP development server. When using php artisan serve, the problem does occur. Accessing the website from Apache or Nginx web servers does not cause any problems. Is there a solution to fix this issue?

vahiddabbagh commented 1 year ago

After several days of rigorous code review and testing, I have discovered that I needed to include the "SystemRoot=C:\WINDOWS" environment variable in the snappy config file. With this addition, any external links or images are now properly rendered in the generated PDF.

I am uncertain about the root cause of this issue. I hope the package author can identify and implement a more effective solution.

'pdf' => [ 'enabled' => true, 'binary' => env('WKHTML_PDF_BINARY', 'wkhtmltopdf'), 'timeout' => false, 'options' => [], 'env' => [ 'SystemRoot' => 'C:\WINDOWS' ], ],

GeraZgVic commented 2 months ago

Excelent, thanks!!