cal*_*n24 5 dompdf laravel laravel-5 laravel-5.5
我想在 Laravel 5.5 中使用 Dompdf 从 Blade 模板制作 pdf 发票。
问题是,当单击下载按钮时,页面正在加载,大约 3 分钟后,pdf 开始下载。
为什么要花这么长时间?
下载链接
<a href="{{ route('admin.download-invoice', $order->OrderID) }}" target="_blank" class="btn btn-danger"><i class="fa fa-file-pdf-o"></i> Download Invoice</a>
Run Code Online (Sandbox Code Playgroud)
网络路线:
Route::get('/order/download-invoice/{OrderID}', 'Admin\AdminOrderController@downloadOrderInvoice')->name('admin.download-invoice');
Run Code Online (Sandbox Code Playgroud)
一个简单的模板(invoice.blade.php)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other
head content must come *after* these tags -->
<title>Invoice</title>
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}" media="screen">
</head>
<body>
<div>{{ $invoice->InvoiceTitle }} </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
下载发票控制器功能:
use Barryvdh\DomPDF\Facade as PDF;
public function downloadOrderInvoice($OrderID){
$invoice = Invoice::where('OrderID', $OrderID)->first();
$pdf = PDF::loadView('invoice.invoice', compact('invoice'))->setPaper('a4', 'landscape');
return $pdf->download('invoice.pdf');
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?我错过了什么?
更新
清除标头并使用 EXTERNAL CDN bootstrap 可以工作。
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
Run Code Online (Sandbox Code Playgroud)
为什么不使用本地引导程序使用资产???
<link href="{{asset('css/bootstrap.min.css')}}" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7495 次 |
| 最近记录: |