mpdf / mpdf

PHP library generating PDF files from UTF-8 encoded HTML

Home Page:https://mpdf.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: Undefined array key "s"

carloscodde opened this issue · comments

Guidelines

Description of the bug

vendor/mpdf/mpdf/src/Tag/Br.php line 60
$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];

$mpdf->writeHTML($html);

mPDF version

8.2

PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)

8.2

Reproducible PHP+CSS+HTML snippet suffering by the error

<p><b style="font-size: 0.73rem;"><u><br></u></b></p><p><b style="font-size: 0.73rem;"><u><br></u></b></p><p><b style="font-size: 0.73rem;"><u>test</u></b><br></p><table border="0" cellpadding="0" cellspacing="0" width="662" style="width: 498pt;">
 <colgroup><col width="63" style="mso-width-source:userset;mso-width-alt:2304;width:47pt">
 <col width="64" span="5" style="width:48pt">
 <col width="57" style="mso-width-source:userset;mso-width-alt:2084;width:43pt">
 <col width="74" span="3" style="mso-width-source:userset;mso-width-alt:2706;
 width:56pt">
 </colgroup><tbody><tr height="20" style="mso-height-source:userset;height:15.6pt">
  <td colspan="10" height="20" class="xl69" width="662" style="height:15.6pt;
  width:498pt">1. Entrega del servicio 1.</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td colspan="10" height="20" class="xl69" width="662" style="height:15.0pt;
  width:498pt">2. Entrega del servicio 2.</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td colspan="10" height="20" class="xl69" width="662" style="height:15.0pt;
  width:498pt">3. Entrega del servicio 3</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;
  width:498pt">- titulo</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;
  width:498pt">- requerimiento 1</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;
  width:498pt">- requerimiento 2</td>
 </tr>
 <tr height="20" style="height:15.0pt">
  <td height="20" class="xl66" colspan="10" style="height:15.0pt;mso-ignore:colspan">- requerimiento 3</td>
 </tr>
 <tr height="18" style="mso-height-source:userset;height:14.1pt">
  <td height="18" class="xl65" width="63" style="height:14.1pt;width:47pt"><br></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="57" style="width:43pt"></td><td class="xl65" width="74" style="width:56pt"></td><td class="xl65" width="74" style="width:56pt"></td><td class="xl65" width="74" style="width:56pt"></td></tr>
 <tr height="20" style="height:15.0pt">
 </tr>
 <tr height="19" style="mso-height-source:userset;height:14.45pt">
 </tr></tbody></table><p><br></p><p style="text-align: center; "><b>TEST TEST TEST.</b></p><p style="text-align: center; "><b><br></b></p>

If that's actually a full php example, you need to mark it as code so it doesn't get interpreted:

```
code here
```

Si en realidad se trata de un ejemplo completo de PHP, debes marcarlo como código para que no se interprete:

<p><b style="font-size: 0.73rem;"><u><br></u></b></p><p><b style="font-size: 0.73rem;"><u><br></u></b></p><p><b style="font-size: 0.73rem;"><u>test</u></b><br></p><table border="0" cellpadding="0" cellspacing="0" width="662" style="width: 498pt;">
<colgroup><col width="63" style="mso-width-source:userset;mso-width-alt:2304;width:47pt">
<col width="64" span="5" style="width:48pt">
<col width="57" style="mso-width-source:userset;mso-width-alt:2084;width:43pt">
<col width="74" span="3" style="mso-width-source:userset;mso-width-alt:2706;
width:56pt">
</colgroup><tbody><tr height="20" style="mso-height-source:userset;height:15.6pt">
 <td colspan="10" height="20" class="xl69" width="662" style="height:15.6pt;
 width:498pt">1. Entrega del servicio 1.</td>
</tr>
<tr height="20" style="height:15.0pt">
 <td colspan="10" height="20" class="xl69" width="662" style="height:15.0pt;
 width:498pt">2. Entrega del servicio 2.</td>
</tr>
<tr height="20" style="height:15.0pt">
 <td colspan="10" height="20" class="xl69" width="662" style="height:15.0pt;
 width:498pt">3. Entrega del servicio 3</td>
</tr>
<tr height="20" style="height:15.0pt">
 <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;
 width:498pt">- titulo</td>
</tr>
<tr height="20" style="height:15.0pt">
 <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;
 width:498pt">- requerimiento 1</td>
</tr>
<tr height="20" style="height:15.0pt">
 <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;
 width:498pt">- requerimiento 2</td>
</tr>
<tr height="20" style="height:15.0pt">
 <td height="20" class="xl66" colspan="10" style="height:15.0pt;mso-ignore:colspan">- requerimiento 3</td>
</tr>
<tr height="18" style="mso-height-source:userset;height:14.1pt">
 <td height="18" class="xl65" width="63" style="height:14.1pt;width:47pt"><br></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="57" style="width:43pt"></td><td class="xl65" width="74" style="width:56pt"></td><td class="xl65" width="74" style="width:56pt"></td><td class="xl65" width="74" style="width:56pt"></td></tr>
<tr height="20" style="height:15.0pt">
</tr>
<tr height="19" style="mso-height-source:userset;height:14.45pt">
</tr></tbody></table><p><br></p><p style="text-align: center; "><b>TEST TEST TEST.</b></p><p style="text-align: center; "><b><br></b></p>

ready

Can you make a minimal example including php?
Also, that html is not really valid, but it looks like it's coming from a Microsoft product, so that's not really surprising.

Here is the example: It appears that removing the init_set commands allows for a preview, but this was not the case with older versions. Additionally, the format looks completely different. Finally, it still points to an undefined variable in the MPDF class.

<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

require_once '../../lib/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();

$html = '<p><u><br></u></p><p><u><br></u></p><p><u>Notas importantes respecto al servicio</u><br></p><table border="0" cellpadding="0" cellspacing="0" width="662" style="width: 498pt;"><br />
<br />
<br />
<br />
<br />
<tbody><tr height="20" style="mso-height-source:userset;height:15.6pt"><br />
 <td colspan="10" height="20" class="xl69" width="662" style="height:15.6pt;<br />
 width:498pt">1. Entrega del servicio: a coordinar.</td><br />
</tr><br />
<tr height="20" style="height:15.0pt"><br />
 <td colspan="10" height="20" class="xl69" width="662" style="height:15.0pt;<br />
 width:498pt">2. Los trabajos están cotizados para ejecutarse de lunes a<br />
 viernes en horario de 08:30 a 17:30 hrs.</td><br />
</tr><br />
<tr height="20" style="height:15.0pt"><br />
 <td colspan="10" height="20" class="xl69" width="662" style="height:15.0pt;<br />
 width:498pt">3. Por parte del cliente:</td><br />
</tr><br />
<tr height="20" style="height:15.0pt"><br />
 <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;<br />
 width:498pt">- Estacionamiento para nuestro camión o vehículo de laboratorio.</td><br />
</tr><br />
<tr height="20" style="height:15.0pt"><br />
 <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;<br />
 width:498pt">- Contar con los servicios de higiene básicos (baño, agua<br />
 potable) para nuestros técnicos.</td><br />
</tr><br />
<tr height="20" style="height:15.0pt"><br />
 <td colspan="10" height="20" class="xl70" width="662" style="height:15.0pt;<br />
 width:498pt">- Disponibilidad total de la(s) balanza(s).</td><br />
</tr><br />
<tr height="20" style="height:15.0pt"><br />
 <td height="20" class="xl66" colspan="10" style="height:15.0pt;mso-ignore:colspan">-<br />
 Tener grúa horquilla para el traslado de masas patrones y operario de ésta,<br />
 en el caso de plataformas.</td><br />
</tr><br />
<tr height="18" style="mso-height-source:userset;height:14.1pt"><br />
 <td height="18" class="xl65" width="63" style="height:14.1pt;width:47pt"><br></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="64" style="width:48pt"></td><td class="xl65" width="57" style="width:43pt"></td><td class="xl65" width="74" style="width:56pt"></td><td class="xl65" width="74" style="width:56pt"></td><td class="xl65" width="74" style="width:56pt"></td></tr><br />
<tr height="20" style="height:15.0pt"><br />
</tr><br />
<tr height="19" style="mso-height-source:userset;height:14.45pt"><br />
</tr></tbody></table><p><br></p><p style="text-align: center; ">EN EL CASO EVENTUAL QUE EL EQUIPO NO SUPERE LAS PRUEBAS DE CALIBRACIÓN, ESTO NO ES RESPONSABILIDAD DEL LABORATORIO DE METROLOGiA COVERY S.A. Y LOS TRABAJOS SERÁN FACTURADOS DE ACUERDO A LOS VALORES COTIZADOS.</p><p style="text-align: center; "><br></p>';


$mpdf->writeHTML($html);

$mpdf->Output('test.pdf', 'I');

Can you make a minimal example? It appears to be something with the <br> tag, so find out which one it is.

Your line breaks in the "full" example code between <table and <tbody or between tr tags don't make sense. You even have br tags inside other HTML tag parameters. Use well-formed HTML and the error should not appear (as it does not with your previous HTML code examples).

Closing as "unable to reproduce", can reopen with more concise code example previewing the error.