html - How I can break my document correctly with DOMPDF? -
i want generate pdf dompdf through dynamic content. creating table this:
<?php $language = $this->input->cookie('language'); if (!isset($language)) { $language = $core_settings->language; } ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="author" content=""/> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="invoice.css" type="text/css" charset="utf-8" /> <style type="text/css"> @page { margin: 0; } .pages { margin: .5in; } .other-pages{ padding:60px; } .first-page { margin: 0in; background-color: black; height: 100%; width: 100%; position:absolute; background-image: url('https://www.example.com/wp-content/uploads/2015/09/example-cover1.jpg'); background-position: bottom center; background-repeat: no-repeat; background-size: 100%; } .first-page + * { page-break-before: always; } </style> </head> <body> <div class="pages first-page"></div> <div class="other-pages"> <h2>title</h2> <div class="round"> <table id="table" class="tablesorter" cellspacing="0"> <thead> <tr class="header"> <th width="5%">#</th> <th width="95%">tarea</th> </tr> </thead> <tbody> <?php $i = 0; $sum = 0; $row=false; ?> <?php foreach ($tasks $task):?> <tr <?php if($row){?>class="even"<?php } ?>> <td><?php echo $i; ?></td> <td><?php echo $task->name; ?><br><?php echo strip_tags($task->description); ?></td> </tr> <?php $i++; endforeach; $row = true; ?> </tbody> </table> </div> </div> </body> </html>
when generate pdf have this:
- cover page (without margin)
- table dynamic content
- full blank page (the problem)
- table dynamic content (it's same table always)
how can fix blank page?
note: content of table depends of content, height depends of content, cannot supose x fields , break page.
when dompdf splits content across pages duplicates styling on element. means following style copied split element, causing page break:
.first-page + * { page-break-before: always; }
since want page break after first page use following instead:
.first-page { page-break-after: always; }
at least 1 issue has been logged related problem: "doubling" of page breaks when page-break-before applied long element
Comments
Post a Comment