samedi 11 avril 2015

DOMPDF - Redirect after stream PDF

I'm generating a dynamic table with DOMPDF. When a form is submitted, $_POST variables are sent to test.php:



<?php
session_start();

$theTemplate = 'test.php';

function renderToPDF($templateFile)
{
require_once("./dompdf/dompdf_config.inc.php");
ob_start();
include $templateFile;
$contents = ob_get_clean();

if ($contents !== false)
{
$dompdf = new DOMPDF();
$dompdf->load_html($contents);
$dompdf->render();
$dompdf->stream("Custom_Data.pdf");

}
}

renderToPDF($theTemplate);
?>


tabletest.php has a table with dynamic values, including some $_POST from the form and some variables from a MYSQL table. When the form is submitted, the PDF is generated successfully, but is there any way to do a redirect to another page after the PDF is downloaded? I didn't find a conclusive answer to similar questions (Create PDF with DOMPDF and Redirect and How to generate pdf file using dompdf and redirect to another page)...


Aucun commentaire:

Enregistrer un commentaire