如何使用 Laravel PDF 库在 php 下载 pdf 文件?
How do I download a pdf file in php Using Laravel PDF library?
所以这在 the library 中有很好的记录,但我无法让它工作。考虑以下因素:
$pdf = PDF::loadView('modules.efapreports.pdf.invoice', [
'invoiceData' => $this->collection,
'organization' => $organization,
'invoiceNumber' => $this->formFields['invoice_number'],
'invoiceDate' => $this->formFields['invoice_date'],
'dueDate' => $this->formFields['due_date'],
'payementTerms' => $this->formFields['payment_terms'],
'gst' => 1.05,
]);
$pdf->save(storage_path(
'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
));
$pdf->download(storage_path(
'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
));
这完美地保存了它,但没有下载它。我必须加载 pdf 文件吗?
您可以使用包dompdf来解决与pdf相关的问题。
https://packagist.org/packages/dompdf/dompdf
return PDF::loadView('modules.efapreports.pdf.invoice', [
'invoiceData' => $this->collection,
'organization' => $organization,
'invoiceNumber' => $this->formFields['invoice_number'],
'invoiceDate' => $this->formFields['invoice_date'],
'dueDate' => $this->formFields['due_date'],
'payementTerms' => $this->formFields['payment_terms'],
'gst' => 1.05,
])->download();
所以这在 the library 中有很好的记录,但我无法让它工作。考虑以下因素:
$pdf = PDF::loadView('modules.efapreports.pdf.invoice', [
'invoiceData' => $this->collection,
'organization' => $organization,
'invoiceNumber' => $this->formFields['invoice_number'],
'invoiceDate' => $this->formFields['invoice_date'],
'dueDate' => $this->formFields['due_date'],
'payementTerms' => $this->formFields['payment_terms'],
'gst' => 1.05,
]);
$pdf->save(storage_path(
'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
));
$pdf->download(storage_path(
'efapinvoices/' . $this->getPath() .'/'. $this->getFileName() . $this->getExtension()
));
这完美地保存了它,但没有下载它。我必须加载 pdf 文件吗?
您可以使用包dompdf来解决与pdf相关的问题。 https://packagist.org/packages/dompdf/dompdf
return PDF::loadView('modules.efapreports.pdf.invoice', [
'invoiceData' => $this->collection,
'organization' => $organization,
'invoiceNumber' => $this->formFields['invoice_number'],
'invoiceDate' => $this->formFields['invoice_date'],
'dueDate' => $this->formFields['due_date'],
'payementTerms' => $this->formFields['payment_terms'],
'gst' => 1.05,
])->download();