0
I am using DOMPDF to compile my reports, however I can not relate in summary the contents of respective topics.
session_start();
require __DIR__."/vendor/autoload.php";
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->setIsPhpEnabled(true);
$dompdf = new Dompdf($options);
$sumario = '';
foreach($_SESSION['sumario'] as $index=>$titulo){
$sumario .= "<div>";
$sumario .="<span>{$index}. {$titulo}</span>";
$sumario .="<p>x</p>"; // Aqui mora o problema, não consigo relacionar este valor!
$sumario .="</div>";
}
ob_start();
$documento = $_SESSION['documento'];
require __DIR__."/pdf.php";
$pdf = ob_get_clean();
//echo $pdf; die;
$dompdf->loadHtml($pdf);
$dompdf->setPaper("A4");
$dompdf->render();
$dompdf->stream("file.pdf",["Attachment" => false]);
I did it in a very simple way, the $_SESSION['document'] is basically an html file, where the 'H1' are the topics, the subtopic 'H2' and 'p' are the common texts.
The $_SESSION['sumario'] was something I did in desperation, trying to make the sumario. It’s like this :
$_SESSION['sumario'] = array(
[1] => 'Titulo 01',
[2] => 'Titulo 02',
[3] => 'Titulo 03
);
Both sessions infected in "pdf.php";
Your example will suit me, but that’s not what I need. I think I was a little confused on the question, so I edited it to try to be more precise. What I need is number the summary with the pages of each topic.
– Guilherme Solis
I still can not understand. What would be the "X" in
<p>x</p>
?– Isaac Bruno
This is where I would put the topic page. For example if Title 01 were on page 02, it would be <span>1. Title 01</span><p>02</p>";
– Guilherme Solis