How to overgive a template to a dompdf script?

admin

Administrator
Staff member
i wanted to ask, what would be the best way, to generate a dynamical pdf?

My Script generates a template from a predefined HTML code and replace the values with my current ones.

The Problem now, how do i get this information to my dompdf script?
The idea is,that someone should klick on a button and can download the generated PDF.(it's not a big deal)

In an Example I found a solution, that someone has use a $_SESSION-Variable.

Code:
<?php
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
date_default_timezone_set('Asia/Manila');
$tym = date('g:i s');
$filename = 'print'.$tym;
$dompdf->load_html($_SESSION['prints']['table']);

$dompdf->render();
$dompdf->stream($filename. ".pdf", array("Attachment" => 0));
?>

<a href="http://kyokasuigetsu25.wordpress.com/2011/07/14/how-to-use-dompdf-with-css/" rel="nofollow">here</a>

But i don't think this wouldn't be a very good solution, because my table could be between 100 and 300 rows.

The Second solution my friend has suggest,was to save the html in a MysqlTable and save also a sessionID and timestamp for this user, so that i don't have collisions and could identified him.
When the entry was 1 hour old i should delete it.

Has someone a better solution?

Edit: Now i have a 3rd Solution, I think it's better then the 2 before.

How would it be, that I save the HTML-Template in an extern file and will save in the DB the place where the file exists.
When it is 1 hour old i will delete it on the same request and recreate it.