2016-08-19 7 views
0

laravelでdompdfを使用して請求書を作成しています。私がそのイメージを使用するまで私はうまく動作します。Laravel dom pdf画像の問題

管理、請求書のテンプレートが含まれているコントローラ

public function generateInvoice(Request $request) 
{ 
    $user = Auth::user(); 
    $pdf  = PDF::loadView('pdf.invoice', $user); 
    return $pdf->download('invoice.pdf'); 
} 

と請求書閲覧ページで...

<style> 
 
.block{ 
 
\t display: block; 
 
} 
 
.minifont12{ 
 
\t font-size: 12px; 
 
} 
 
.minifont10{ 
 
\t font-size: 10px; 
 
} 
 
.col-md-45{ 
 
\t width: 45%; 
 
\t display: inline-block; 
 
} 
 
.col-md-30{ 
 
\t width: 30%; 
 
\t display: inline-block; 
 
} 
 
.col-md-25{ 
 
\t width: 24%; 
 
\t display: inline-block; 
 
} 
 
.bluecolor{ 
 
\t background-color: #C5C5EC; 
 
} 
 
.midtop{ 
 
\t 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"> 
 
\t <div class="minifont12 block" style="margin-top:20px;"> 
 
\t <strong>Sold By:</strong> SRM Smart Solutions Pvt. Ltd.<br> 
 
\t \t <span class="minifont10"> 
 
\t \t \t Building No. 29, Third Floor, Central Market, West Punjabi Bagh, Delhi-110026 
 
\t \t </span> 
 
\t </div> 
 
\t <hr> 
 
\t <div class="col-md-45"> 
 
\t \t Order Id : BT121178273<br> 
 
\t \t Order Date : 24-05-2016<br> 
 
\t \t Invoice Date : 25-05-2016<br> 
 
\t \t CIN No. : U72300DL2015PTC281652 
 
\t </div> 
 
\t <div class="col-md-30"> 
 
\t \t Avinash<br> 
 
\t \t H.No 30-45-5/26, Chandigari colony east, rohit cottage lane, opp. krupa comlex lane, r.k.puram post, 500 056, hdy.<br> 
 
\t \t Hyderabad, telangana - 500056<br> 
 
\t \t 8099473211 
 
\t </div> 
 
\t <div class="col-md-25"> 
 
\t \t <span class="midtop bluecolor"> 
 
\t \t \t *Keep this invoice for return and refund purposes 
 
\t \t </span> 
 
\t </div> 
 
</div>

が、私は、コードを実行すると...それはなりますエラーメッセージを表示する 最大実行時間が60秒を超えました

これの背後にある問題を教えてください。

+0

'php artisan vendor:publish'を実行してから' config/'ディレクトリに行き、' dompdf.php'を編集してから 'show_warnings = true'を設定しましたか?あなたに少し良いエラー報告を与えるべきです。また、pdfビューに画像をベース64のエンコードされた画像として渡してから、PDFの内容をPDFで使用できますか?あなたのソース '$ src = public_path()。 '/ img/minilogo.jpg';'を設定し、ビューに渡す '$ image'変数を作成してください:' $ image = 'data:' .mime_content_type($ src base26_encode(file_get_contents($ src)); ' Ohgodwhy

+0

を設定しました。別のイメージ(パブリックサーバから)を使用しても問題はありますか? – BrianS

答えて

1

非常に大きな画像を使用した場合、同じ問題が発生しました。私は最大の実行時間を変更して、このラインを追加してpdfの作成を開始することで問題を解決しました:ini_set('max_execution_time', 120);。この設定は、Webサーバー上で実行されるすべてのスクリプトに適用されるため、必要に応じてphp.iniファイルでこれを変更することもできます。また、php.iniファイルを変更した後にWebサーバーを再起動する必要があります。

これを解決するその他のオプションについては、hereを参照してください。