简体   繁体   中英

Laravel 6 DOMPDF image rendering

I am using barryvdh/laravel-dompdf to convert Blade template views into PDF documents, everything works great except imagery.

In one PDF I have an image with the following markup.

<img 
    class="newable-logo" 
    src="{{ public_path('assets/images/newable-logo-blue.png') }}"
    alt="{{ public_path('assets/images/newable-logo-blue.png') }}"
>

On my local machine, this resolves to

C:\\laragon\\www\\nvl-portal\\public\\assets/images/newable-logo-blue.png

This doesn't render on the PDF locally but this exact code works as expected on my staging and production servers.

Is this normal behaviour?

I always thought DOMPDF used the fully qualified path?

it can happen due to path separator deference between windows and linux. you can try DIRECTORY_SEPARATOR in php. eg:

src="{{ public_path('assets' .DIRECTORY_SEPARATOR .'images' .DIRECTORY_SEPARATOR . 'newable-logo-blue.png') }}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM