I have a page with some data on a table, and I've styled the CSS so everything gets printed correctly. However, due to the nature of the page, it is certainly better to print "orizontally", so that there's more width for the table. I know this is a setting that the user should select himself from the printing options of the system, but I was wondering if there is any way to make the print panel preselect that option for the user.
Asked
Active
Viewed 651 times
3 Answers
0
Unfortunately not - printing is a system function outside of the scope of the DOM, so CSS won't let you touch it.

Fluidbyte
- 5,162
- 9
- 47
- 76
0
@page {
size: landscape;
}
See CSS3 Module: Paged Media 3.3 Page size. However, the CSS3M:PM is a six year old working draft and didn't get that much attention in the last years, so you'll have to check whether your targeted browser actually support the rule.

Zeta
- 103,620
- 13
- 194
- 236
0
In short, under web development, you can't touch the printer using javascript. You can't even know whether there's a printer attached to the computer viewing your website. And after you issued window.print(), you can't find out whether the page has been printed successfully.
If your requirement is setting the layout to landscape, here's a CSS trick for you:
<style type="text/css" media="print">
.landScape
{
width: 100%;
height: 100%;
margin: 0% 0% 0% 0%;
filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=3);
}
</style>
<body class="landScape">
...
</body>
Just try if works for you.

Sameera Thilakasiri
- 9,452
- 10
- 51
- 86
-
*"here's a CSS trick for you"*, which only works in IE. Also OP neither stated that he wants to use JavaScript, nor did he tag the question with JavaScript. – Zeta Nov 11 '12 at 16:46