【发布时间】:2016-08-19 07:54:32
【问题描述】:
我在 laravel 中使用 dompdf 创建发票。它对我来说很好,直到我在其中使用图像。
管理控制器
public function generateInvoice(Request $request)
{
$user = Auth::user();
$pdf = PDF::loadView('pdf.invoice', $user);
return $pdf->download('invoice.pdf');
}
在包含发票模板的发票查看页面中...
<style>
.block{
display: block;
}
.minifont12{
font-size: 12px;
}
.minifont10{
font-size: 10px;
}
.col-md-45{
width: 45%;
display: inline-block;
}
.col-md-30{
width: 30%;
display: inline-block;
}
.col-md-25{
width: 24%;
display: inline-block;
}
.bluecolor{
background-color: #C5C5EC;
}
.midtop{
margin-top: 50px;
}
</style>
<div class="header" style="position:relative; top:10; width:100%; ">
<img src="http://localhost:8000/img/minilogo.jpg">
<div style="text-align:center; margin-top:-20px;">Retail Invoice/Bill</div>
<div style="text-align:right">Invoice No. #BTR_PB_000052</div>
</div>
<div class="content">
<div class="minifont12 block" style="margin-top:20px;">
<strong>Sold By:</strong> SRM Smart Solutions Pvt. Ltd.<br>
<span class="minifont10">
Building No. 29, Third Floor, Central Market, West Punjabi Bagh, Delhi-110026
</span>
</div>
<hr>
<div class="col-md-45">
Order Id : BT121178273<br>
Order Date : 24-05-2016<br>
Invoice Date : 25-05-2016<br>
CIN No. : U72300DL2015PTC281652
</div>
<div class="col-md-30">
Avinash<br>
H.No 30-45-5/26, Chandigari colony east, rohit cottage lane, opp. krupa comlex lane, r.k.puram post, 500 056, hdy.<br>
Hyderabad, telangana - 500056<br>
8099473211
</div>
<div class="col-md-25">
<span class="midtop bluecolor">
*Keep this invoice for return and refund purposes
</span>
</div>
</div>
但是当我运行代码时...它会显示错误消息 超过 60 秒的最大执行时间
请告诉我这背后的问题..
【问题讨论】:
-
你是否完成了
php artisan vendor:publish,然后进入你的config/目录,然后编辑dompdf.php,然后设置show_warnings = true?应该给你更好的错误报告。另外,您可以尝试将图像作为 base 64 编码图像传递给 pdf 视图,然后在 PDF 中使用该图像的内容吗?设置您的源$src = public_path().'/img/minilogo.jpg';,然后创建要传递给视图的$image变量:$image = 'data: '.mime_content_type($src).';base64,'.base64_encode(file_get_contents($src));现在设置<img src="'. $image .'"/> -
如果您使用不同的图像(例如来自公共服务器),您还有问题吗?