dompdf and jpgraph generated images

852 views
Skip to first unread message

darmot

unread,
Apr 4, 2011, 9:11:59 AM4/4/11
to dompdf
Hi,

i just try to include a jpgraph on the fly gerenated gantt diagramm
into a pdf without success.

The image tag with the call to the php generator script is ignored by
dompdf:
<img alt="GANTT" id="gantt_img" src="image/php/my_gantt.php?......"
border="0" \>
Then I put a inline php script section into the html template.
<script type="text/php">
if ( isset($pdf) ) {
$gant = $pdf->open_object();
$pdf->image("image/php/mygantt.php?.....", "jpg");
$pdf->close_object();
$pdf->add_object($gant);
}
</script>

I'm still using a header (PNG) and footer (Text) in the generated pdf,
so inline php is still working.

Any Ideas?
Bye
Tom

BrianS

unread,
Apr 4, 2011, 3:06:25 PM4/4/11
to dom...@googlegroups.com
How are you loading your HTML document into DOMPDF? Dynamically-generated images have to be accessed through a server, otherwise the PHP script that generated them will not work. You'll need to either load via your web server (e.g. $dompdf->load_html('http://example.com...')) or link to a full URL for your images (e.g. <img alt="GANTT" id="gantt_img" src="http://example.com/image/php/my_gantt.php?......" border="0"  \> ).

darmot

unread,
Apr 6, 2011, 8:44:26 AM4/6/11
to dompdf
The generated image can be accesses directly through the webserver.
I load the html into dompdf by doing this:

$dompdf = new DOMPDF();
$dompdf->load_html($body_start.$pdf_text.$body_end);
$dompdf->set_paper("A4");
$dompdf->render();
$dompdf->stream("pdf_generator.pdf");

$body_start contains the start of the html output: <html><head>....
and the inline php to include a header and a footer on every page.

$pdf_text contains a html table and the jpgraph image:
<table>
.....
<tr>
<td colspan="5">
<img alt="GANTT" id="gantt" src="http://gant.mydomain.de/image/php/
mygantt.php?mySID=xyz" border="0" style="margin-top:5px;margin-left:
17px;" >
</td>
</table>

$body_end closes the <html><body> TAGs.

If I call the gant graph by typing the url in the browser, the graph
appears.
If I echo the ($body_start.$pdf_text.$body_end) instead of using
dompdf everything looks great too.

So at the moment, I let write the generated graphs into static png
files by the mygantt.php script.
The html contains then: <img alt="GANTT" src="image/php/temp/
gantt_[feld:user_id].png" width="655" border="0" />
This is done before the user is able start the pdf output by clicking
on the icon. Now the image appears in the pdf.
But this is not perfect, because a lot of files will be created
regardless of whether they are needed or not.




Reply all
Reply to author
Forward
0 new messages