I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings?
And what are the options amongst browsers.
I have a HTML report, which needs to be printed landscape because of the many columns. It there a way to do this, without the user having to change the document settings?
And what are the options amongst browsers.
This also worked for me:
not working in Firefox 16.0.2 but it is working in Chrome
Quoted from CSS-Discuss Wiki
I created a blank MS Document with Landscape setting and then opened it in notepad. Copied and pasted the following to my html page
The print preview shows the pages in a landscape size. This seems to be working fine on IE and Chrome, not tested on FF.
My solution:
This works in
IE
,Firefox
andChrome
It's not enough just to rotate the page content. Here is a right CSS which work in the most browsers (Chrome, Firefox, IE9+).
First set body
margin
to 0, because otherwise page margins will be larger than those you set in the print dialog. Also setbackground
color to visualize pages.margin
,border
andbackground
are required to visualize pages.padding
must be set to the required print margin. In the print dialog you must set the same margins (10mm in this example).The size of A4 page is 210mm x 297mm. You need to subtract print margins from the size. And set the size of page's content:
I use 276mm instead of 277mm, because different browsers scale pages a little bit differently. So some of them will print 277mm-height content on two pages. The second page will be empty. It's more safe to use 276mm.
We don't need any
margin
,border
,padding
,background
on the printed page, so remove them:Note that the origin of transformation is
0 0
! Also the content of landscape pages must be moved 276mm down!Also if you have a mix of portrait and lanscape pages IE will zoom out the pages. We fix it by setting
-ms-zoom
to 1.665. If you'll set it to 1.6666 or something like this the right border of the page content may be cropped sometimes.If you need IE8- or other old browsers support you can use
-webkit-transform
,-moz-transform
,filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3)
. But for modern enough browsers it's not required.