NucleosDompdfBundle icon indicating copy to clipboard operation
NucleosDompdfBundle copied to clipboard

The render of images do not work

Open tydoo opened this issue 1 year ago • 4 comments

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 avatar May 20 '24 00:05 tydoo

I have resolved with this :

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

Please update docs

tydoo avatar May 20 '24 12:05 tydoo

@tydoo did you add the images folder for resolving that

minddifferent avatar Jun 24 '24 09:06 minddifferent

@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

rimoi avatar Jul 15 '24 12:07 rimoi

Hi all,

It does not work with Asset Mapper either. I've tried with or without compiling assets, tried every possibility in the src of the img element... Anyone has successfully managed to use this lib with asset mapper of SF?

Cheers,

Laurent

LaurentSanson avatar Dec 13 '24 12:12 LaurentSanson