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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@Media Print question

Status
Not open for further replies.

dkn

Programmer
Oct 11, 2000
60
0
0
US
Hi

I'm trying to set the default page orientation for one of the pages in my application to lanscape for printing purposes.

I've read that the following should do the trick

<style type=&quot;text/ccs&quot;>
@media print
{
size: landscape;
}
</style>

However this seems to have no effect.

Am I missing something here?. Is there anything else I need to do to get this to work?.

Any help greatly appreciated, as this is driving me nuts :eek:)

David.
 
If I validate the above code it gives a parse error for landscape; not sure what exactly that means though. According to the specs it should be valid as you can use auto, landscape, inherit etc

Here is the spec

Perhaps the browser does not support it? Ihave you checked this?


::
 
I'm running Internet Exploder 5.50, and according to the spec it should run after IE 4.x.....

I'm going to see if I can get any of the other @ media stuff working and take it from there.

Thanks for the input,,, :eek:)

Has anyone actually implemented this feature, who could validate that the syntax is indeed correct?.

David.
 
I've tried using the @media print to change various attibutes of my page when printing (fonts, margins etc) and nothing seems to work.

How about server settings?, is there anywhere on the server that could prevent me making programatic changes to the print settings?. We are running IIS 4 btw.

Still stuck and looking for help

David :eek:)
 
Just in the process of doing so.... ;-)

I've found one site with a working example


Heres the code they use...

<html>
<head>
<style>
@media screen
{
p.test {font-family:verdana,sans-serif; font-size:14px}
}

@media print
{
p.test {font-family:times,serif; font-size:10px}
}
@media screen,print
{
p.test {font-weight:bold}
}
</style>
</head>
<body>
....
</body>

...and when you preview the page, hey presto it works...

The question is what does the 'p.test' bit stand for?. Is this the page name??

David :eek:)
 
This is a paragraph of the test class.
The problem with your style above is that your not setting that attribute for a specific element. In other words:
Code:
<style>
@media print{
   p{
      color:red;
   }
}
</style>
The above style says to make all text in paragraphs red during print preview and print.
In your case you may want to set the attribute on the body (don't remember, sorry):
Code:
<style>
@media print{
   body{
      size: landscape;
   }
}
</style>

Now for the bad news, if I remember correctly this hasn't been implemented in any of the browsers yet. I may be a little out of date now, so let us know what you find.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
I see where you are coming from, but it still doesn't work even if I spcify BODY as the element I want to landscape...

The @media functionality has definitely been implemeted in IE 4.x and later browsers... check out the link above, they have a working example.

I'm not convinced that the p.test part of our example...

@media print
{
p.test {font-family:times,serif; font-size:10px}
}

refers to an element. If it was just specifying that all Paragraphs were to be serif size 10, surely it would just be P?..

Still searchin for answers... story of my life :eek:)

David.
 
1) p.test refers to all paraghraph elements that are class test:
Code:
<p class=&quot;test&quot;>a test para</p><p>a standard, unaffected para</p>

2) I know the media print is implemented in IE, I was actually referring to the landscape attribute, sorry, should have clarified. I haven't actually seen this implemented successfully, though I have used the media print several times other the past few months and absolutely love it :)

I'm not sure the body is the correct element to set it on, you may want to check a CSS refernce to make sure. It may be that in the past when i have tried it I was placing the attribute on the wrong element, which is why it didn't work for me.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
I've been searching the net for the past couple of hours and can't find a working example where the page orientation is set, so maybe there are problems with it.

I see what you mean now by p.test..thanks :eek:)

I'll check out the CSS spec and see if that throws anymore light on it. If I get it working I'll post the results here.

Thanks for your input...

David.
 
Nice try, but no cigar :( Still comes out portrait.

I spent a couple of days trying to find a working example of this, but without success. Methinks its a bit of a dead duck!

Thanks for your input anyhoo!

Cheers

David :eek:)
 
I think it is an un-implemented CSS2 attribute thing. Kind falls into the &quot;things I am waiting for catagory&quot; like max-width, min-width, max-height, min-height. (Those are going to rock!)

I'm not a geek, honest, my computer tells me so...
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top