laravel snappy pdf:获取错误文件未创建
我的数据库中大约有1500名学生,我需要为每个学生生成一张发票。为此,我正在使用这个库。当我尝试生成时,出现以下错误: 未创建文件“/var/www/skmpastebimaslt/public_html/storage/checks/24767 Dominykas Butkevičius 1581703819.pdf”(命令:/usr/local/bin/wkhtmltopdf--lowquality“/tmp/knp_snappy5e462; e28b5d61f2.13362077.html“/var/www/skmpastebimaslt/public_html/storage/checks/24767 Dominykas butkevius 1581703819.pdf”) 为四个用户生成发票,然后应用程序崩溃。最有趣的是,即使错误显示文件不是创建的,但它是创建的,我仍然可以在我的存储文件夹中找到它 我的代码:laravel snappy pdf:获取错误文件未创建,laravel,wkhtmltopdf,knp-snappy,Laravel,Wkhtmltopdf,Knp Snappy,我的数据库中大约有1500名学生,我需要为每个学生生成一张发票。为此,我正在使用这个库。当我尝试生成时,出现以下错误: 未创建文件“/var/www/skmpastebimaslt/public_html/storage/checks/24767 Dominykas Butkevičius 1581703819.pdf”(命令:/usr/local/bin/wkhtmltopdf--lowquality“/tmp/knp_snappy5e462; e28b5d61f2.13362077.html
public function saveCheckPdf(Student $student, Check $check = null, $fileName = null)
{
if (empty($fileName)) {
$fileName = 'kvitas_' . time() . '.pdf';
}
$path = storage_path('checks/' . $fileName . '.pdf');
$this->renderCheckPdf($student, $check)->save($path);
return $path;
}
private function renderCheckPdf(Student $student, Check $check = null)
{
$bills = $this->billRepository->getCurrentSeasonBills($student->id);
$payments = $this->paymentRepository->getCurrentSeasonPayments($student->id);
$fileName = $student->fullname . ' kvitas';
$billsSum = $bills->sum('sum');
$paymentsSum = $payments->sum('sum');
if (empty($check)) {
$check = !empty($student->checks[0]) ? $student->checks[0] : false;
}
return newPDF::loadView('student.check_pdf', compact('student', 'payments', 'bills', 'billsSum', 'paymentsSum', 'fileName', 'check'));
}
然后我只需循环遍历每个用户并在控制器中调用saveCheckPdf方法,如下所示
$this->pdfService->saveCheckPdf($student, null, $student->id . ' ' . $student->fullname . ' ' . time());
也许有人也面临同样的问题?我自己找到了解决办法。我收到一个错误,因为我在文件名中使用了立陶宛字母。