8
I am generating a PDF file with reports generated through PHP.
In the PDF file are generated a number x of reports and each report has a number y of pages. I need to know if this y number is even or odd, if it’s odd I need to add a blank page.
The report is being generated in a View of the Laravel so:
@foreach($relatorio as $r)
<div class="page-break">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris vel metus dui.
Etiam aliquam convallis nisi eu hendrerit.
Fusce tincidunt molestie aliquam.
Pellentesque porta nunc sit amet est accumsan luctus.
Cras fringilla pellentesque nulla at convallis...
</div>
@endforeach
I’m doing the page break at the end of each report with the CSS class:
.page-break{
page-break-after:always;
}
I thought to use Javascript to count how many pages are generated within the div .page-break
but I have no idea how to make that count
I also thought about counting the total pages and dividing by the number of reports but I don’t know how to do it either. Note: all reports have the same number of pages.
What do you use in PHP to create the document? TCPDF?
– Peter