Laravel dom pdf图像问题

时间:2016-08-19 07:54:32

标签: laravel dompdf

我在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秒

请告诉我这背后的问题是什么..

2 个答案:

答案 0 :(得分:1)

使用非常大的图像时遇到了同样的问题。我通过在开始创建pdf之前添加此行来更改最大执行时间来解决此问题:iperf -c 172.18.41.17 -p 458 -t 10 。如果您愿意,也可以在php.ini文件中更改此项,只需确保您知道自己在做什么,因为此设置适用于在Web服务器上执行的所有脚本。在php.ini文件中进行更改后,您还必须重新启动Web服务器。

我们讨论了其他一些解决此问题的方法here

答案 1 :(得分:-1)

您可以使用此代码:

<img src="{{ public_path("images/a.png") }}">

或者可以:

<div style="background: url({{ public_path("images/a.png"}})">text</div>
相关问题