Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter Php将生成的图形保存为图像并转换mpdf_Codeigniter_Graph_Mpdf_Phpgraphlib - Fatal编程技术网

Codeigniter Php将生成的图形保存为图像并转换mpdf

Codeigniter Php将生成的图形保存为图像并转换mpdf,codeigniter,graph,mpdf,phpgraphlib,Codeigniter,Graph,Mpdf,Phpgraphlib,我试图在codeigniter中创建一个图形,并将其转换为pdf。对于pdf转换,我使用mpdf 对于图形生成,我尝试了几种方法。包括-phpgraphlib、phpmygraph5.0以及gcharts 我想gchart正在用javascript生成图形。。 所以我尝试了phpgraphlib和phpmygraph5。但我现在面临的问题是,图形是在浏览器中生成的。如何将其转换为图像并将其作为数据数组发送到我的pdf视图中 以下是我的pdf生成代码: $this->CI->load-

我试图在codeigniter中创建一个图形,并将其转换为pdf。对于pdf转换,我使用mpdf

对于图形生成,我尝试了几种方法。包括-phpgraphlib、phpmygraph5.0以及gcharts

我想gchart正在用javascript生成图形。。 所以我尝试了phpgraphlib和phpmygraph5。但我现在面临的问题是,图形是在浏览器中生成的。如何将其转换为图像并将其作为数据数组发送到我的pdf视图中

以下是我的pdf生成代码:

$this->CI->load->library('pdf');
$pdf = $this->CI->pdf->load();
$style = 'assets/pdf/pdf.css';
$stylesheet = file_get_contents( $style);

//$pdf-> $img = file_get_contents($this->graph());

$graph_result['points'] = $points;
$graph_result['profile'] = $profile;
$graph_result['image'] = file_get_contents($this->mygraph());

$content = $this->CI->load->view('pdf/graph_pdf_view', $graph_result,  TRUE);
$pdf->WriteHTML($stylesheet,1); 
$pdf->WriteHTML($content,2);

$pdf->Output('Graph.pdf', 'I'); 
下面是生成图形的函数:

public function graph()
{

//graph library loads.......
include (APPPATH.'libraries/phpgraphlib/phpgraphlib.php');

$graph = new PHPGraphLib(650,200);
$data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033, 
"5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024, 
"10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036, 
"14" => .0028, "15" => .0025);
//print_r($data);
$graph->addData($data);
$graph->setTitle('PPM Per Container');
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor('maroon');
$graph->setDataValues(true);
$graph->setDataValueColor('green');
$graph->setGoalLine(.0025);
$graph->setGoalLineColor('yellow');
$graph->createGraph();
return $graph;   
}


当我从pdf生成函数调用graph函数时,它会在浏览器上直接生成图形。。不转到我加载pdf视图的下一段代码。。如何将生成的图形保存为图像并仅将该图像传递到pdf视图???

将生成的图形保存为.png图像文件很容易,您必须看到:

根据文档,该命令如下所示:

$graph = new PHPGraphLib(650,200, "image.png")