PDFをマージするPHPライブラリ PDFMerger で致命的エラー
こちらのライブラリを使用してPDFを連結する以下のようなコードを書いた場合、致命的エラーが出る場合があります。
$pdfm = new PDFMerger; for($i=1; $i<$client_count; $i++) { $pdfm->addPDF("tmp/$i.pdf", 'all'); } $pdfm->merge('file', 'comp.pdf');
Fatal error: Uncaught exception 'Exception' with message 'Error outputting PDF to 'file'.'
対処法
どうやら既知の問題らしく、公式のISSUEにてとりあえずの打開策が掲載されてましたので、ライブラリ本体の修正で直ります。
else { if($fpdi->Output($outputpath, $mode)) { return true;
else { if($fpdi->Output($outputpath, $mode) == '') { return true;