我要預覽並使用此代碼下載訂單發票PDF:PDF數據顯示,但文件沒有下載
public function generatePDFByIdOrder()
{
$order = new Order(1); //I want to download the invoice PDF of $order_id '1'
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('Can\'t load Order object');
}
$order_invoice_collection = $order->getInvoicesCollection();
$this->generatePDF($order_invoice_collection, PDF::TEMPLATE_DELIVERY_SLIP);
}
public function generatePDF($object, $template)
{
$pdf = new PDF($object, $template, Context::getContext()->smarty);
$pdf->render();
}
並用下面的代碼調用它: $order = new order(); echo $order->generatePDFByIdOrder();
如何操作該數據以下載pdf文件?
你可能需要添加一個合適的'頭()' – Jakuje