Buenas amigos antes que nada saludos y gracias a los que lean el comentario.
Tengo un error al generar un PDF en un sistema con Laravel usando la librería https://github.com/barryvdh/laravel-dompdf pero me da un error cuando hay una tabla muy grande que debe dividirse en 2 páginas les muestro en la imágen si la tabla o una imagen es muy grande luego no me carga las siguientes paginas y me carga todo el contenido que viene en el tope de la pagina.
El código que estoy usando para generar el PDF en el controlador es el siguiente;
/**
* Generate pdf file.
*
* @param int $id
* @return document pdf
*/
public function pdf($id)
{
$document = $this->show($id);
$body = str_replace("\t", "", $document['body']);
$bodyTemp = explode("\n", $body);
// 1 - convertir las url de las imagenes en base64
foreach($bodyTemp as $k => $v){
if (strpos($v, '<img') !== false) {
$img = str_replace(asset('uploads/documents/'.$document['titlefile']), "", $v);
$img = str_replace('<img src="/', "", $img);
$img = str_replace('"/>', "", $img);
$imagesbase64 = Ibsa::loadImage(public_path('uploads' .DIRECTORY_SEPARATOR. 'documents' .DIRECTORY_SEPARATOR. $document['titlefile'] .DIRECTORY_SEPARATOR. $img));
$body = str_replace(asset('uploads/documents/' . $document['titlefile'] .'/'. $img), $imagesbase64, $body);
$document['body'] = $body;
}
}
// 2 - obtener el html de la vista
$html = view($this->selectTemplate(
$document['front']['journal-meta']['journal-title'],
$document['article-type'],
'pdf'
))->with('d', $document)
->with('body',$body);
// 3 - generar el pdf
$pdf = PDF::loadHTML($html)->setPaper('a4', 'portrait');
return $pdf->stream();
}
y la vista con la que estoy genrando el PDF es la siguiente:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{!! $d['front']['article-meta']['article-title'] !!}</title>
<style>.fl{float:left}.fr{float:right}.w10{width:10%}.w20{width:20%}.w25{width:25%}.w30{width:30%}.w40{width:40%}.w50{width:50%}.w60{width:60%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w90{width:90%}.body img,.w100,table{width:100%}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.bg1{background:#F1F1F1}.bg2{background:red}.bg3{background:#00f}.bg4{background:pink}.bg5{background:#ff0}.front h1{font-size:14pt}.abstract,.authors,.trans-abstract{font-size:10pt}.aff,.cita,.doi,.history{font-size:10pt;text-align:justify}.cita,.doi,.history{padding-top:10px;word-wrap:break-word}.abstract h2,.trans-abstract h2{font-size:12pt;margin:0}.trans-abstract h2{margin-top:10px}.abstract p,.abstract strong,.trans-abstract p,.trans-abstract strong{font-size:9pt;margin:0}table{font-swize:10pt}.title{font-size:12pt;font-weight:700}.body img{max-width:700px;max-height:950px!important}.body .sec>.title{font-size:16pt;font-weight:700;border-left:2px solid #ccc;padding-left:10px}.body .sec>div>.title{font-size:14pt;font-weight:700;margin-top:10px}.body .sec>div>div>.title{font-size:13pt;font-weight:700;margin-top:10px}.body .fig{margin:10px 0}.body .fig .title{margin:0;font-weight:400!important;font-size:12pt}.ack p,.ref p{font-size:10pt}.ref p{background:#F1F1F1;padding:10px;border-left:1px solid #CCC}</style>
</head>
@php $meses = array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"); @endphp
<body>
<div class="wrapper">
<section class="front">
<div class="w100 bg1">
<div class="fl w70">
<strong style="padding-right:10px;margin-right:10px;border-right:1px solid #CCCCCC;">
{!!$d['front']['journal-meta']['journal-title']!!}
{!!$d['front']['article-meta']['issue']!!}:
{!!$d['front']['article-meta']['fpage']!!}-
{!!$d['front']['article-meta']['lpage']!!}
</strong>
{!!$meses[$d['front']['article-meta']['pub-date']['month'] - 1]!!} - {!!$d['front']['article-meta']['pub-date']['year']!!}
</div>
<div class="fl w30 text-right">{!!$d['front']['article-meta']['subject']!!}</div>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
<div class="w100" style="padding:15px 0 0 0;">
<h1 class="text-center w90" style="margin:0 auto;">{!!$d['front']['article-meta']['article-title']!!}</h1>
</div>
<div style="clear:both;"></div>
<div class="w100" style="padding:10px 0 0 0;">
<h1 class="text-center w90" style="margin:0 auto;">
{!!$d['front']['article-meta']['trans-title']!!}
</h1>
</div>
<div style="clear:both;"></div>
<div class="w100 text-center authors" style="padding:10px 0;">
@foreach($d['front']['article-meta']['authors'] as $author)
<span style="author text-center margin-right:15px;white-space:nowrap;">
<nobr>
{!!$author['surname']!!} {!! $author['given-names']!!}
@foreach($author['xrefs'] as $xref)
<a href="#{!!$xref['ref-rid']!!}"><sup>{!!$xref['ref-sup']!!}</sup></a>
@endforeach
{{-- expr --}}
@if(isset($author['contrib-id']))
@php
$urlparts = parse_url($author['contrib-id']);
$scheme = @$urlparts['scheme'];
if ($scheme === 'https' OR $scheme === 'http') $url = $author['contrib-id'];
else $url = 'https://orcid.org/' . $author['contrib-id'];
@endphp
@endif
@if($url != '')
@php
$var = Ibsa::loadImage(public_path('templates' .DIRECTORY_SEPARATOR. 'template01' .DIRECTORY_SEPARATOR. 'orcid.jpg'));
@endphp
<a href="{!!$url!!}" target="_blank" >
<img src="{{$var}}" alt="orcid" style="width:12px;margin-right:15px;" />
</a>
@endif
</nobr>
</span>
@endforeach
</div>
<div style="clear:both;"></div>
<div class="w100">
<table>
<tr valign="top">
<td style="width:120px;">
<div class="w70">
@php $i = 1; @endphp
@foreach($d['front']['article-meta']['affs'] as $aff)
<div class="w100 aff">
<div class="fl w10" id="'{!!$aff['label']!!}">{!!$aff['label']!!}</div>
<div class="fl w90">{!!$aff['original']!!}<br><br></div>
</div>
<div style="clear:both;"></div>
@php @$i++; @endphp
@endforeach
@if(isset($d['front']['article-meta']['author-notes']['corresp-label']))
<div class="w100 aff">
<div class="fl w10" id="{!!$d['front']['article-meta']['author-notes']['corresp-label']!!}">
@php echo $i; @endphp
</div>
<div class="fl w90">
{!!$d['front']['article-meta']['author-notes']['corresp']!!}
<br><br></div>
</div>
<div style="clear:both;"></div>
@endif
<div class="cita">{!!$d['back']['fn-group']['fn']['p']!!}
</div>
<div style="clear:both;"></div>
<div class="history">
@foreach($d['front']['article-meta']['history'] as $history)
@php
if(ucfirst($history['type']) == 'Received'): $typeHistory = 'Recibido';
elseif(ucfirst($history['type']) == 'Rev-recd'): $typeHistory = 'Revisado';
elseif(ucfirst($history['type']) == 'Accepted'): $typeHistory = 'Aceptado';
@endphp
@endif
<p style="margin:0;">{{ucfirst($typeHistory)}}:
<span>{!!$history['day']!!} {!! $meses[$history['month'] - 1] !!} {!! $history['year'] !!}</span>
</p>
@endforeach
</div>
<div style="clear:both;"></div>
<div class="doi">
DOI:
<a href="http://dx.doi.org/{!!$d['front']['article-meta']['article-id']!!}" target="_blank">
http://dx.doi.org/{!!$d['front']['article-meta']['article-id']!!}
</a>
</div>
<div style="clear:both;"></div>
</div>
</td>
<td style="width:550px;">
<div style="margin-left:-65px;width:93%;">
<section class="abstract">
<h2>{!!$d['front']['article-meta']['abstract']['title']!!}</h2>
{!!$d['front']['article-meta']['abstract']['content']!!}
</section>
<section class="trans-abstract">
<h2>{!!$d['front']['article-meta']['trans-abstract']['title']!!}</h2>{!!$d['front']['article-meta']['trans-abstract']['content']!!}
</section>
</div>
</td>
</tr>
</table>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</section>
<div style="page-break-after:always;"></div>
<section class="body">
{!! $d['body'] !!}
</section>
<div style="page-break-after:always;"></div>
<section class="back">
<div class="col ack">
<h2>{!! $d['back']['ack']['title'] !!}</h2>
<p style="background:transparent;border:0;padding:0;">
{!! $d['back']['ack']['content'] !!}</p>
</div>
<div class="col ref">
<h2>{!! $d['back']['refs']['title'] !!}</h2>
@foreach($d['back']['refs']['ref'] as $ref)
<p id="{!! $ref['ref-id'] !!}">{!!$ref['mixed-citation']!!}</p>
@endforeach
</div>
</section>
</div>
</body>
</html>
Gracias, les agradezco de ante mano toda la ayuda que me puedan brindar en la solución del error.