Closed konstpap2 closed 4 years ago
master
I have a function to generate pdf-file in Yii2
private function savePDFPrint($data,$path) { .... $filename = $data['content']; ... $content = $this->renderPartial('/result/resultPrint',['id' => $id], true, true);// быстро $pdfPrint = new Pdf([ 'mode' => Pdf::MODE_UTF8, 'filename' => $path, 'destination' => Pdf::DEST_FILE, 'content' => $content, 'cssFile' => $cssfile, 'options' => [ ], 'methods' => [ 'SetTitle' => $title, 'SetSubject' => $subject, 'SetAuthor' => $author, 'SetCreator' => $creator, 'SetKeywords' => $keywords, ] ]); $pdfPrint->render(); ... return true; }
when i trying to call this function more than once
... savePDFPrint($data1,$path1); savePDFPrint($data2,$path2); ...
i got a error
"PHP Notice 'yii\base\ErrorException' with message 'Constant _MPDF_TEMP_PATH already defined"
I solved this in this way
/yii2-mpdf/src/Pdf.php, line 249 if( !defined( '_MPDF_TEMP_PATH' )) static::definePath('_MPDF_TEMP_PATH', "{$prefix}tmp{$s}"); if( !defined( '_MPDF_TTFONTDATAPATH' )) static::definePath('_MPDF_TTFONTDATAPATH', "{$prefix}ttfontdata{$s}");
But may be you have a better solution...
yii2-mpdf version: 1.0.6
[x] The bug happens consistently across all tested browsers
[x] This bug happens when using yii2-mpdf without other plugins.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Prerequisites
master
branch of yii2-mpdf.I have a function to generate pdf-file in Yii2
when i trying to call this function more than once
i got a error
I solved this in this way
But may be you have a better solution...
yii2-mpdf version: 1.0.6
[x] The bug happens consistently across all tested browsers
[x] This bug happens when using yii2-mpdf without other plugins.