I'm trying to create a PDF file via mPDF where the sheets have the following orientation:
___________
| Page 1 |
| |
| Portrait |
| |
___________
___________
| Page 2 |
| TOC |
| Portrait |
| |
___________
__________________
| Page 3 |
| Landscape |
| |
__________________
___________
| Page 4 |
| |
| Portrait |
| |
___________
However, changing the orientation of page 3 makes mPDF create a blank page between page 2 (TOC) and page 3. You can view the created document here.
The PDF is created in HTML and then processed to mPDF. The code is as follows:
HTML:
<html>
<head>
<style>
@page page-landscape { size: landscape; }
@page page-portrait { size: portrait; }
div.landscape {
page: page-landscape;
}
div.portrait {
page: page-portrait;
}
</style>
</head>
<body>
<div>
<div>First page - displayed Portrait. The second page should be the TOC (portrait) and the 3rd should be on landscape</div>
</div>
<tocpagebreak />
<div class="landscape">
<bookmark content="TOC entry" level="0"/>
<tocentry content="TOC entry" level="0"/>
<p>TOC entry - Shouldn\'t have a empty page before</p>
</div>
<div class="portrait">
another page
</div>
</body>
</html>
PHP
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html);
$mpdf->Output();
I've tried a number of things to make this work, without success. I'll list some of them:
- Using
toc-selector="page-portrait"on the<tocpagebreak>tag - Using
toc-orientation="P"on the<tocpagebreak>tag - Adding a
<pagebreak orientation="L" />after the<tocpagebreak> - Using
class="landscape"in thedivafter the TOC, using the@pageselector, as shown in this example - Setting the variable
autoPageBreaktofalseon mPDF's constructor - Wrapping the pages in
divand messing around with the position of<pagebreak>
I was using mPDF v6.0 and now I'm updating to mPDF v8.0.1. This issue occurs on all versions (6, 7 and 8). While on version 6 I used a hack by adding $mpdf->DeletePages(2); after $mpdf->WriteHTML($html); but this has two major problems:
- This method is undocumented and seems buggy
- With this, the page number doesn't match the correct pages, so I can't add page number on the footer
Is there any way to accomplish this without a blank page? Or a viable workaround?
from mPDF creates blank page after TOC when using different orientation
No comments:
Post a Comment