Estou a tentar criar um pdf com uma tabela que recebe valores de varíaveis php.
A página corre perfeitamente, mas quando utilizo o DOMPDF para criar o pdf da página ele da-me o seguinte erro :
Fatal error: Uncaught Error: Call to undefined method DOMProcessingInstruction::getAttribute() in C:\xampp\htdocs\organizar\dompdf\src\Cellmap.php:554 Stack trace: #0 C:\xampp\htdocs\organizar\dompdf\src\Cellmap.php(518): Dompdf\Cellmap->add_frame(Object(Dompdf\FrameDecorator\Inline)) #1 C:\xampp\htdocs\organizar\dompdf\src\Cellmap.php(518): Dompdf\Cellmap->add_frame(Object(Dompdf\FrameDecorator\TableRowGroup)) #2 C:\xampp\htdocs\organizar\dompdf\src\FrameReflower\Table.php(532): Dompdf\Cellmap->add_frame(Object(Dompdf\FrameDecorator\Table)) #3 C:\xampp\htdocs\organizar\dompdf\src\FrameReflower\Table.php(408): Dompdf\FrameReflower\Table->get_min_max_width() #4 C:\xampp\htdocs\organizar\dompdf\src\FrameDecorator\AbstractFrameDecorator.php(895): Dompdf\FrameReflower\Table->reflow(Object(Dompdf\FrameDecorator\Block)) #5 C:\xampp\htdocs\organizar\dompdf\src\FrameReflower\Block.php(845): Dompdf\FrameDecorator\AbstractFrameDecorator->reflow(Object(Dompdf\FrameDecorator\Block)) #6 C:\xampp\htdocs\organizar\dompdf\src\FrameDecora in C:\xampp\htdocs\organizar\dompdf\src\Cellmap.php on line 554
Alguem sabe do que possa ser?
A página é a seguinte :
<?php
session_start();
require '../../app/listadeferias.php';
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<img src="../public/assets/logo.jpeg" style="width: 8%; margin: 0 30px;">
<h1 style="text-align: center;"> Férias Marcadas </h1> <table class="table" style="width: 100%; margin-bottom:40px; margin-top: 15px; ">
<thead>
<tr>
<th scope="col">Data Inicial</th>
<th scope="col">Data Final</th>
<th scope="col">Numero de dias pedidos</th>
<th scope="col">Ano referente</th>
<th scope="col">Dias de férias disponiveis</th>
</tr>
</thead>
<tbody>
<?php foreach ($resultado as $key => $value) { ?>
<tr>
<th scope="col"><?= $value["dferiasinicial"]?></th>
<th scope="col"><?= $value["dferiasfinal"]?></th>
<th scope="col"><?= $value["ndias"]?></th>
<th scope="col"><?= $value["ano"]?></th>
<th scope="col"><?= $value["feriasrestantes"]?></th>
</tr>
<?php } ?>
</tbody>
</table>
</body>
</html>
Dompdf :
use Dompdf\Dompdf;
$document = new Dompdf();
$document-> loadHtml(file_get_contents('../public/pages/imprimepgina.php'));
$document->setPaper('A4', 'landscape');
$document->render();
$document->stream();
?>
$document-> loadHtml(file_get_contents('../public/pages/imprimepgina.php'));
Eu digo isso porque eu uso essa biblioteca, A diferença é que montei o html na mesma página e armazenei numa variável.