Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting print options - @page

Status
Not open for further replies.

MrsKensington

Programmer
Sep 26, 2001
28
GB
I've created a link that uses the window.print() javascript call to bring up the print dialog.
By default the page is printed in Portrait, but I want to print it in Landscape.
I was looking at the @page rule thing which you should be able to specify size, margin and page breaks... this is what I have in my stylePrint.css
Code:
<style TYPE=&quot;text/css&quot;><!--BODY { background: #ADD8E6; }
@page { size: landscape; margin: 2cm }
[...]
--></style>
and then stick this in my web page
Code:
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../../Time_Keeping/stylePrint.css&quot;>
the href is right as other bits in the stylesheet work. Yet when i click my print button Portrait is still selected and so when i print its printed in portrait.

What am i doing wrong?

thanks in advance

p.s. I shouldn't think it would make any difference but these pages are created by a perl script
 
I was having the same probelm, trying to print in Landscape rather than portrait. I posted the question on several sites and no one seemed to know how to accomplish this. I had several people tell me it wasn't possible, so if you figure it out let me know.
 
Are the style tags included in the css-file?
In that case you should remove them.
//Daniel
 
no that didn't work it still prints portrait.

i tried changing the margin property to 1cm and it had no obvious effect, but that tells me what i knew already, it doesn't work :-(
 
ok found out why it doesn't work!

only IE 6 fully implements CSS Level 1 and it doesn't support CSS2 yet. @page is in CSS Level 2 so it wont work in IE :-(

Oh well if i leave the code in, when viewed with a browser that does support CSS2 it'll work!
 
Any one know if @page is supported in IE6 SP1 then? I really need to do some printing (invoked from JavaScript )in landscape mode. Unfortunately, JavaScript can't change page settings either!!
 
Nope, sure isn't. From what I understand, it was SUPPOSED to be, but I don't know what became of it. Perhaps the next version of IE will support it. Kevin
slanek@ssd.fsi.com

&quot;Life is what happens to you while you're busy making other plans.&quot;
- John Lennon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top