瀏覽代碼

restore static images rendering

Olivier Massot 1 年之前
父節點
當前提交
aa7c9d2c4a
共有 2 個文件被更改,包括 9 次插入5 次删除
  1. 4 0
      src/Service/Export/Encoder/PdfEncoder.php
  2. 5 5
      templates/export/licence_cmf.html.twig

+ 4 - 0
src/Service/Export/Encoder/PdfEncoder.php

@@ -26,6 +26,8 @@ class PdfEncoder implements EncoderInterface
 
     public function encode(string $html, array $options = []): string
     {
+//        file_put_contents(Path::getProjectDir() . '/content.tmp.html', $html);
+//        die;
         $tempDir = Path::getProjectDir() . '/var/tmp';
         if (!is_dir($tempDir)) {
             mkdir($tempDir);
@@ -42,6 +44,8 @@ class PdfEncoder implements EncoderInterface
 
         $options = new Options();
         $options->setDefaultFont('DejaVu Sans Bold');
+        $options->setIsRemoteEnabled(true);
+        $options->setChroot(Path::getProjectDir() . '/public');
 
         $dompdf = new Dompdf($options);
 

+ 5 - 5
templates/export/licence_cmf.html.twig

@@ -174,13 +174,13 @@
                             <tbody>
                             <tr>
                                 <td width="340" class="relative">
-                                    <img src="{{ absPath('images/cmf_licence.png') }}"
+                                    <img src="{{ 'images/cmf_licence.png' }}"
                                             width="170" height="86"/>
                                     <span id="year_head">{{ licence.year }}</span>
                                 </td>
                                 <td width="340">
                                     <div align="right">
-                                        <img src="{{ absPath('images/cmf-reseau.png') }}"
+                                        <img src="{{ 'images/cmf-reseau.png' }}"
                                                 width="200" height="86"/>
                                     </div>
                                 </td>
@@ -237,7 +237,7 @@
                             <td width="80" id="avatar">
                                 <div align="center">
                                     {% if(licence.logo is null) %}
-                                        <img src="{{ absPath('images/picto_face.png') }}"
+                                        <img src="{{ 'images/picto_face.png' }}"
                                              width="85"
                                              height="82"/>
                                     {% else %}
@@ -261,7 +261,7 @@
                                 <div align="center">
                                     {% if(licence.personAvatar is null) %}
                                         <img
-                                                src="{{ absPath('images/picto_face.png') }}"
+                                                src="{{ 'images/picto_face.png' }}"
                                                 width="85"
                                                 height="82"/>
                                     {% else %}
@@ -286,7 +286,7 @@
                         <td width="70" valign="middle"
                             style="vertical-align: top;">
                             <div align="center">
-                                <img src="{{ absPath('images/cmf_licence.png') }}"
+                                <img src="{{ 'images/cmf_licence.png' }}"
                                      height="45"/>
                                 <span id="year_card">{{ licence.year }}</span>
                             </div>