nucleos / NucleosDompdfBundle

📜 This bundle provides a wrapper for using dompdf inside symfony.
https://nucleos.rocks
MIT License
38 stars 12 forks source link

The render of images do not work #549

Open tydoo opened 3 months ago

tydoo commented 3 months ago

With the default option, render of images do not work.

Symfony 6.4 Dev run on Windows

config:

nucleos_dompdf:
    defaults:
        chroot: '%kernel.project_dir%/public/assets'
        isRemoteEnabled: true

controller:

#[Route('/testpdf', name: 'pages.test.pdf', methods: ['GET'])]
    public function testPDF(
        DompdfWrapperInterface $wrapper
    ): Response {
        return $wrapper->getStreamResponse(
            $this->renderView('PDF/example.html.twig'),
            'example.pdf',
            [
                'Attachment' => false,
            ]
        );
    }

assets: image

Twig:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        {% block stylesheets %}
            {% for file in encore_entry_css_files('app') %}
                <style>
                    {{file_get_contents(file)}}</style>
            {% endfor %}
        {% endblock %}
    </head>
    <body>
        <img src={{ absolute_url( asset('assets/logo_ministere.png') ) }}>

    </body>
</html>

PDF : image

How to resolve this ?

Thanks

tydoo commented 3 months ago

I have resolved with this :

<img src="images/logo_ministere.png">

Please update docs

minddifferent commented 2 months ago

@tydoo did you add the images folder for resolving that

rimoi commented 1 month ago

@minddifferent I fixed it, the correction I inspired from this Pull Request : #Pull request 253

 <img src="{{ absolute_url( asset('assets/img/CDC.png') ) }}" alt="..."

Capture d’écran du 2024-07-15 14-28-16

I've left the configuration file exactly as @tydoo