I am using jasper report iReport tool to generate some reports from the database.
All done, I am using a library called Lavela/jasperPHP to generate reports via API and export them to pdf, xls ...
My problem is, I want to open the report in a frame or container in my website, the situation now is that i can download reports to pdf and xls, or open the report in html page but not in my website template in a iframe or container or an element.
Any help ?
THIS IS MY PHP CONTROLLLER USING LARAVEL 5.1
$output = public_path() . '/report/'.time().'_CancelAck';
$output = public_path() . '/report/'.time().'_CancelAck';
$ext = "pdf";
$data_file = public_path() . '/report/CancelAck.xml';
$driver = 'xml';
$xml_xpath = '/CancelResponse/CancelResult/ID';
\JasperPHP::process(
public_path() . '/report/report1.jrxml',
$output,
array($ext),
array(),
array(
'driver' => 'mysql',
'username' => 'root',
'password' =>'',
'host' => 'localhost',
'database' => 'test',
'port' => '3306',
),
array('data_file' => $data_file, 'driver' => $driver, 'xml_xpath' => $xml_xpath),
false,
false
)->execute();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($output.'.'.$ext));
flush();
readfile($output.'.'.$ext);
unlink($output.'.'.$ext);
}
}
this is my routes :
Route::get('/', function () {
return view('welcome');
});
Route::get('getreportService/','ReportController@getReport');
when i call the service from the url i get the report as i want, but i need to show this report in my website.
You are requesting the server to create downloadable content.
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
You need to find the proper header for it to return html/css content.