0
I am trying to create a pdf with a table that receives php variable values.
The page runs perfectly, but when I use DOMPDF to create the pdf of the page it gives me the following error :
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
Does anyone know what it might be?
The page is as follows :
<?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();
?>
Does this file path really exist? The error seems that it cannot load this file.
$document-> loadHtml(file_get_contents('../public/pages/imprimepgina.php'));
I say this because I use this library, The difference is that I built html on the same page and stored it in a variable.– Bruno
There is, if I remove the part of the code where the foreach starts until it ends it creates a pdf with the beginning of the table
– Marco Silva