Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setOptions method breaks image loading #793

Closed
daviderix88 opened this issue Jun 5, 2021 · 3 comments · Fixed by #974
Closed

setOptions method breaks image loading #793

daviderix88 opened this issue Jun 5, 2021 · 3 comments · Fixed by #974
Labels

Comments

@daviderix88
Copy link

daviderix88 commented Jun 5, 2021

When you set options, images are not loaded:

Controller:

$pdf = App::make('dompdf.wrapper');
$pdf->loadView('print.certificate', $evaluation)->setPaper('a4', 'landscape');
$pdf->setOptions([]); // it does not matter what options you set

View:
<img src="{{ public_path('images/certificate_tpl.jpg') }}">
Result:
Image not found or type unknown

If you remove the setOptions, the image is loaded.

Tested on: Laravel 8, Debian Linux, Laravel development server (php artisan serve), PHP 7.4.

@betoflakes
Copy link

I was stuck in the same problem. I added setOptions and the images not load anymore.

@vladski
Copy link

vladski commented Jun 23, 2021

The issue is that method setOptions resets ALL options to default values from vendor, including "chroot". That is directory, that Dompdf is allowed to access files from, which is in dompdf.php config file set to Laravel base path, but by setOptions it is reset to vendor root dir.

Do not use setOptions unless you want set ALL of the options. Get current Options object and set what you need like this:

$pdf->getDomPDF()->getOptions()->setIsPhpEnabled(true);

@stale
Copy link

stale bot commented Aug 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf.
If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants