管理画面の受注管理の検索一覧より、各受注の帳票をPDFで出力する事が出来ます。
さて、その帳票(納品書)をダウンロードせずに、ブラウザからPDFを開いた場合、IEだとエラーが発生し、表示出来ません。
こんなエラーメッセージが出ます。
「この文書を開くときにエラーが発生しました。ファイルが壊れています。修復できませんでした。」
この障害を回避する為には、
data/pdf/fpdf.php
を以下のよう編集する必要があります。
/* 1024行目付近 */ switch($dest) { case 'I': //Send to standard output if(ob_get_contents()) $this->Error('Some data has already been output, can\'t send PDF file'); if(php_sapi_name()!='cli') { //We send to a browser header('Content-Type: application/pdf'); if(headers_sent()) $this->Error('Some data has already been output to browser, can\'t send PDF file'); // IEでPDFを表示出来るように追加 Start header('Cache-Control: '); header('Pragma: '); // IEでPDFを表示出来るように追加 End header('Content-Length: '.strlen($this->buffer)); header('Content-disposition: inline; filename="'.$name.'"'); } echo $this->buffer; break; case 'D': //Download file if(ob_get_contents()) $this->Error('Some data has already been output, can\'t send PDF file'); if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) header('Content-Type: application/force-download'); else header('Content-Type: application/octet-stream'); if(headers_sent()) $this->Error('Some data has already been output to browser, can\'t send PDF file'); // IEでPDFを表示出来るように追加 Start header('Cache-Control: '); header('Pragma: '); // IEでPDFを表示出来るように追加 End header('Content-Length: '.strlen($this->buffer)); header('Content-disposition: attachment; filename="'.$name.'"'); echo $this->buffer; break; case 'F': //Save to local file $f=fopen($name,'wb'); if(!$f) $this->Error('Unable to create output file: '.$name); fwrite($f,$this->buffer,strlen($this->buffer)); fclose($f); break; case 'S': //Return as a string return $this->buffer; default: $this->Error('Incorrect output destination: '.$dest); }
これで、IEでも正常に納品書PDFが表示出来ました。
でわ。