[thelist] how to embed Jpgraph in FPDF
jothi jothi
jthjothi at yahoo.com
Thu Oct 18 07:46:14 CDT 2007
hello there,
Thanks for those help me in posgresql...
Now i have another problem where i used jograph to generate graphs...i am using FPDF to generate pdf files...when i try to embed the graph with FPDF ,the output was not in pdf file..below is my coding...where is the error?
Anyone have come through this situation before?help me...
<?php
require('mem_image.php');
include('fpdf.php');
$db_name = "wsn";
$table_name = "suhu";
$connection = @mysql_connect("localhost", "12090", "kamala")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$query = "SELECT Node_ID , AVG(voltage),AVG(Temper), AVG(light),AVG(accel_x), AVG(accel_y), AVG(mag_x), AVG(mag_y), AVG(mic),Date from suhu
group by Node_ID";
$result = mysql_query($query) or die(mysql_error());
include ("c:/jpgraph-1.21b/src/jpgraph.php");
include ("c:/jpgraph-1.21b/src/jpgraph_Line.php");
while($row = mysql_fetch_array($result))
{
$data[] = $row["AVG(light)"];
$leg[] = $row[0];
}
$graph = new Graph(250, 150,"auto");
//$graph = new Graph(600,600);
$graph->SetScale("textint");
$graph->img->SetMargin(50,30,50,50);
//$graph->SetBackgroundImage("Blue hills.jpg",BGIMG_FILLFRAME);
$graph->SetShadow();
$graph->xaxis->SetTickLabels($leg);
$lplot = new LinePlot($data);
$lplot->SetFillColor("lightgreen"); // Fill color
$lplot->value->Show();
$lplot->value->SetFont(FF_ARIAL,FS_BOLD);
$lplot->value->SetAngle(45);
$lplot->value->SetColor("black","navy");
$lplot->SetLegend("Light");
$graph->title->Set("Light");
$graph->xaxis->title->Set("Nodes_ID");
$graph->yaxis->title->Set("Light");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->Add($lplot);
$graph->Stroke();
// Put the image in a PDF page
$im = $graph->Stroke(_IMG_HANDLER);
$pdf = pdf_new();
pdf_open_file($pdf, '');
// Convert the GD image to somehing the
// PDFlibrary knows how to handle
$pimg = pdf_open_memory_image($pdf, $im);
pdf_begin_page($pdf, 595, 842);
pdf_add_outline($pdf, 'Page 1');
pdf_place_image($pdf, $pimg, 0, 500, 1);
pdf_close_image($pdf, $pimg);
pdf_end_page($pdf);
pdf_close($pdf);
$buf = pdf_get_buffer($pdf);
$len = strlen($buf);
// Send PDF mime headers
header('Content-type: application/pdf');
header("Content-Length: $len");
header("Content-Disposition: inline; filename=foo.pdf");
// Send the content of the PDF file
echo $buf;
// .. and clean up
pdf_delete($pdf);
?>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the thelist
mailing list