Is there a way to set different page styles with Flying Saucer/iText? I need to have the first couple of pages in landscape, then switch to portrait at a certain page and out.
Any ideas?
Is there a way to set different page styles with Flying Saucer/iText? I need to have the first couple of pages in landscape, then switch to portrait at a certain page and out.
Any ideas?
Nevermind, found the answer. For anyone interested, this is how you do it:
@page land { size:landscape; }
@page port { size:portrait; }
.landscapePage { page:land; }
.portraitPage { page:port; }
voilá!
I'm also trying to switch to landscape in mid document. I have the pages switching just fine, however the text formatting still appears to be formatting to the portrait width, even on landscape pages.
Any ideas?
For anyone still stuck with the problem Derek mentioned, I've found that I need to explicitly set a width on the element that is switching its layout. So with the example div
<div class="portraitPage">
<p>Some page content in portrait</p>
</div>
<div class="landscapePage">
<p>Some page content in landscape</p>
</div>
it will correctly format a portrait page followed by a landscape page, but the content in landscape page will only be as wide as the portrait page, even if the @page land declaration contains a width. What I needed was to set the width directly on the div that has the relevant class applied, so the declaration is something more like
.landscapePage { page:land; width: 29.7cm; }
Be careful though that the width should take into account any margins or padding applied via the @page declaration block.