title: symfony 4 - dompdf loop when display image
body: <p>I try for several days to display images in my PDF generated with <strong>domPDF</strong> on <strong>symfony 4</strong>.</p>
  
  <p>In the pdf, I would like to insert an image from an entity, which I manage with <strong>VichUploader</strong>.</p>
  
  <p>So I proceeded like this:</p>
  
  <p>In my <strong>controller</strong>, I added :</p>
  
  <pre><code>// Configure Dompdf according to your needs
          $pdfOptions = new Options();
          $pdfOptions-&gt;set('isRemoteEnabled', true);
  </code></pre>
  
  <p>In my <strong>Twig</strong>, I display my image like this :</p>
  
  <pre><code>&lt;img style="width:90px;" src="{{absolute_url(vich_uploader_asset(parametresAdmin, 'logoFile'))}}"&gt;
  </code></pre>
  
  <p>But when I start the action, there is a <strong>loop</strong> and I end up having the following <strong>error</strong>:</p>
  
  <blockquote>
    <p>Error: Maximum execution time of 120 seconds exceeded</p>
  </blockquote>
  
  <p>However, if I cancel adding the image, the PDF loads well (but without the image since I do not display it)</p>
  
  <p>I checked on the url of the image was well an absolute way and that it was correct, doing this in my Twig:</p>
  
  <pre><code>{% set var = absolute_url(vich_uploader_asset(parametresAdmin, 'logoFile')) %}
              &lt;pre&gt;
              {{ dump(var) }}
  </code></pre>
  
  <p>And it is ! </p>
  
  <p><a href="https://i.stack.imgur.com/vwQHv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vwQHv.png" alt="enter image description here"></a></p>
  
  <p>And <strong>the path is good</strong>, because I can open the file in a new tab.</p>
  
  <p>I tried to display my image with a split in my <strong>twig</strong> :</p>
  
  <pre><code>{% set var = absolute_url(vich_uploader_asset(parametresAdmin, 'logoFile')) %}
  &lt;img style="width:90px;" src="{{var}}"&gt;
  </code></pre>
  
  <p>Or pass my url from my <strong>controller</strong> to my view in parameter :</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>$html = $this-&gt;renderView('absence/pdf.html.twig', [
              'title' =&gt; "Welcome to our PDF Test",
              'parametresAdmin' =&gt; $parametresAdmin,
              'url' =&gt; "http://127.0.0.1:8000/admin/logo/avatar2.jpg",
          ]);
  </code></pre>
  
  <p><strong>Twig :</strong> </p>
  
  <pre><code>&lt;img style="width:90px;" src="{{url}}"&gt;
  </code></pre>
  
  <p>But same problem. Looping for 120 seconds and error :</p>
  
  <blockquote>
    <p>Error: Maximum execution time of 120 seconds exceeded</p>
  </blockquote>
  
  <p>So I really do not understand why he does not want to post it in the PDF and that it loops. The path is correct, and works on normal views.</p>
  
  <p>Here is my whole code for an overview:</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>/* Uses */
  use Dompdf\Dompdf;
  use Dompdf\Options;
  
  /*Fonction*/
      /**
       * Générer un PDF
       * @Route("/absence/pdf", name="absence_pdf")
       *
       * @return void
       */
      public function createPDF(ParametresAdminRepository $repoParametres)
      {
          $parametresAdmin = $repoParametres-&gt;findAll();
  
          if (isset($parametresAdmin[0])) {
              $parametresAdmin = $parametresAdmin[0];
          } else {
              $parametresAdmin = new ParametresAdmin();
          }
          // Configure Dompdf according to your needs
          $pdfOptions = new Options();
          $pdfOptions-&gt;set('isRemoteEnabled', true);
  
  
  
          // Instantiate Dompdf with our options
          $dompdf = new Dompdf($pdfOptions);
          $dompdf-&gt;set_option('isHtml5ParserEnabled', true);
  
          // Retrieve the HTML generated in our twig file
          $html = $this-&gt;renderView('absence/pdf.html.twig', [
              'title' =&gt; "Welcome to our PDF Test",
              'parametresAdmin' =&gt; $parametresAdmin
          ]);
  
          // Load HTML to Dompdf
          $dompdf-&gt;loadHtml($html);
  
          // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
          $dompdf-&gt;setPaper('A4', 'portrait');
  
          // Render the HTML as PDF
          $dompdf-&gt;render();
  
          // Output the generated PDF to Browser (inline view)
          $dompdf-&gt;stream("mypdf.pdf", [
              "Attachment" =&gt; false,
          ]);
      }
  </code></pre>
  
  <p><strong>And my Twig:</strong> </p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;Title of the PDF&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h4&gt;{{ title }}&lt;/h4&gt;
          &lt;p&gt;Lorem Ipsum&lt;/p&gt;
          {% if parametresAdmin.logoName %}
              &lt;img style="width:90px;" src="{{absolute_url(vich_uploader_asset(parametresAdmin, 'logoFile'))}}"&gt;
          {% endif %}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>EDIT: When I use an absolute path directly from my files, like :</p>
  
  <blockquote>
    <p>"C:\Users\user\Desktop\congesTest2\public\admin\logo\avatar2.jpg"
    It works.</p>
  </blockquote>
  
  <p>But it seems that if the absolute path is :</p>
  
  <blockquote>
    <p>http://........</p>
  </blockquote>
  
  <p>In this case:</p>
  
  <blockquote>
    <p><a href="http://127.0.0.1:8000/admin/logo/avatar2.jpg" rel="nofollow noreferrer">http://127.0.0.1:8000/admin/logo/avatar2.jpg</a></p>
  </blockquote>
  
  <p>It doesn't work. But I need this path</p>
  
  <p>Thanks for your help !</p>