I have a problem when creating a pdf in symfony from the dompdf library.
Namely, it converts pictures but only from one photo, ignoring the other.
Checking the parameters of this photo it has 225x225, 8bit and png format.
So, not thinking much I have stuck all the photos in the same format, width and bits. Of course, it does not work.
I am out of ideas and I do not know what to do because the library only sees one picture and ignores the others.
I changed the format of all the pictures and the size of what works
My code:
<div class="contentImportat">
<p class="description">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris eget accumsan ligula, id vehicula quam. Donec nec efficitur nisi.
Morbi vel ultricies ligula.
</p>
<img class="znak" src="ogien.png">
</div>
<div class="contentCompany">
<span>company: Lorem ipsum dolor</span>
<span>street: Lorem ipsum dolor</span>
<span>country: Lorem ipsum dolor</span>
<span>phone: 921-123-131</span>
<span>fax: 921-123-131</span>
</div>
<hr class="line">
<img class="img" src="ogien.png">
<?php
/**
* @Route("/dom" , name="pdf_dom")
*/
public function domAction()
{
$pdfOptions = new Options();
$pdfOptions->set('defaultFont', 'Arial');
// Instantiate Dompdf with our options
$dompdf = new Dompdf($pdfOptions);
$dompdf = new Dompdf(array('enable_remote' => true));
// Retrieve the HTML generated in our twig file
$html = $this->renderView('pdf/horismall.html.twig');
// Load HTML to Dompdf
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser (force download)
$dompdf->stream("mypdf.pdf", [
"Attachment" => false
]);
}
For generation of PDF, you can use excellent library WKHTMLTOPDF(Laravel Snappy), currently I'm using this library for generating Highcarts and photos and many more things in PDF.
There is a wrapper from knp labs for Symfony called KnpSnappy. You can use it in order to generate your PDF. Laravel snappy is based on this package - you can try to use laravel package too.
Note: Sometimes if you referencing photo with twig or blade(laravel template engine), library could not not render it, so what I'm doing is referencing image with HTML tag(direct link to image), not with (Laravel Blade) or Twig asset option.