Dompf负载永远laravel 4.2
问题描述:
进出口使用dompf试图产生PDF并将其保存到存储文件夹和数据库,问题是当我尝试生成PDF,它永远不会加载,当我使用github它的工作示例代码,它显示“测试”,但是当我尝试加载视图它需要永远。这是代码我使用Dompf负载永远laravel 4.2
$pdf = PDF::loadView('emails.myView',$myData);
return $pdf->stream();
我已经使用download
和save
方法试过了,但好好尝试一下工作和页面加载永远,但永远不会生成PDF文件。
并且该视图仅显示4个或6个元素,其中1个主调用$hist
,返回该视图时没有任何问题。
<style type="text/css">
Bunch of css.
</style>
<table class="center-block">
<tr>
<td colspan="3">
<img src="{{ asset('images/boletin/btn_cabeza.jpg') }}" class="img-responsive center-block">
</td>
</tr>
<tr>
<td rowspan="4" class="aside">
<a href="{{ URL::to('contacto/donaciones') }}">
<img src="{{ asset('images/boletin/btn_dona.jpg') }}" class="img-responsive center-block" >
</a>
<div class="social-container">
<h3>Siguenos en:</h3>
<hr>
<ul>
<li><a href="https://twitter.com/fundaepekeina"><i class="fa fa-twitter"></i></a></li>
<li><a href="http://fundaepekeina.org"><i class="fa fa-instagram"></i></a></li>
<li><a href="https://www.facebook.com/funda.epekeina"><i class="fa fa-facebook"></i></a></li>
<li><a href="https://www.youtube.com/user/fundaepekeina"><i class="fa fa-youtube-play"></i></a></li>
</ul>
</div>
<h2 class="text-blue">Historias Epékeinas</h2>
<br>
@if(count($hist->imagenes) > 0)
<img src="{{ asset('images/news/'.$hist->imagenes->first()->image) }}" class="img-responsive img-boletin" alt="{{ $hist->titles->first()->text }}">
@endif
<div class="bg-green padding-20">
<h2 class="boletin-title">
{{ $hist->titles->first()->text }}
@if(!is_null($hist->subtitle))
{{ $hist->subtitle->titles->first()->text }}
@endif
</h2>
</div>
<hr>
<div class="text-justify">
{{ substr(strip_tags($hist->descriptions->first()->text), 0, 1600) }}[...]
<br>
<a href="{{ URL::to('quienes-somos/historias-epekeinas/'.$hist->slugs->first()->text) }}" class="pull-right">Leer más</a>
</div>
</td>
</tr>
<?php $k = 0;?>
@foreach($article as $a)
@if($k == 0 || $k%2 == 0)
<tr>
@endif
@if(!empty($principal))
@if($a->slugs->first()->text != $principal->id)
<td class="news fixedHeight bg-{{ $colors[$j] }}">
@if(count($a->imagenes) > 0)
<img src="{{ asset('images/news/'.$a->imagenes->first()->image) }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
@else
<img src="{{ asset('images/logo.png') }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
@endif
<h2 class="boletin-title">{{ $a->titles->first()->text }}</h2>
<p class="text-justify">{{ substr(strip_tags($a->descriptions->first()->text), 0, 300) }} [...]</p>
<a target="_blank" href="{{ URL::to('noticias/'.$a->slugs->first()->text) }}" class="btn btn-default btn-xs pull-right">Leer más</a>
<div class="clearfix"></div>
</td>
<?php $k++; ?>
@endif
@else
<td class="news fixedHeight bg-{{ $colors[$j] }}">
@if(count($a->imagenes) > 0)
<img src="{{ asset('images/news/'.$a->imagenes->first()->image) }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
@else
<img src="{{ asset('images/logo.png') }}" class="img-responsive center-block img-boletin" alt="{{ $a->titles->first()->text }}">
@endif
<h2 class="boletin-title">{{ $a->titles->first()->text }}</h2>
<p class="text-justify">{{ substr(strip_tags($a->descriptions->first()->text), 0, 300) }} [...]</p>
<a target="_blank" href="{{ URL::to('noticias/'.$a->slugs->first()->text) }}" class="btn btn-default btn-xs pull-right">Leer más</a>
<div class="clearfix"></div>
</td>
<?php $k++; ?>
@endif
<?php $j++; ?>
@if($j == 4)
<?php $j=0; ?>
@endif
@if(($k != 0 && $k%2 == 0) || $k == count($article))
</tr>
@endif
@endforeach
<tr>
<td colspan="3" class="text-center">
<h3>© Derechos Reservados Funda Epékeina 2016.</h3>
</td>
</tr>
</table>
<div class="container center-block">
<div class="bg-square bg-blue"></div>
<div class="bg-square bg-yellow"></div>
<div class="bg-square bg-green"></div>
<div class="bg-square bg-pink"></div>
</div>
<div class="clearfix"></div>
什么可能是错的?是否有任何其他选择生成pdf。
答
检查,以便这些点:
对于Laravel 4 *我建议你使用这个DOMPDF包装https://github.com/barryvdh/laravel-dompdf/tree/0.4
也许你的观点是试图呈现出的内容页面,尝试要添加动态分页符,可以通过使用page-break-before样式化元素来完成:always;或分页后:始终。尝试删除该foreach并添加1或2个静态元素将其呈现在一个页面中
通过在HTML中使用
return View::make('emails.myView',$myData)->render();
来检查视图中的错误。 检查PHP和HTML sintax,如果某些HTML标记 未关好考虑使用KNP-活泼库Laravel https://github.com/barryvdh/laravel-snappy/tree/0.1
你应该设置你的调试模式上DOMPDF不起作用检查laravel.log文件是否有错误。 –