Most peculiar problem with following code. It returns a pdf report to the browser.
function cart_aspdf() {
trace('cart_aspdf_in');
$file = 'order_WS000250.pdf';
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $file . '"');
$file = APPPATH.'pdfcache/'.$file;
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
trace('cart_aspdf_readfile');
@readfile($file);
trace('cart_aspdf_out');
}
The trace output in opera,firefox,ie,safari is as you would expect:
- cart_aspdf_in
- cart_aspdf_readfile
- cart_aspdf_out
BUT the trace for chrome shows the following which seems to indicate that the function is being called at least twice if not three times. Why should this be so?
- cart_aspdf_in
- cart_aspdf_readfile
- cart_aspdf_out
- cart_aspdf_in
- cart_aspdf_readfile
- cart_aspdf_in
- cart_aspdf_readfile
- cart_aspdf_out
The problem does not occur if I omit the content-type line but then chrome shows the raw pdf data which is no use