I am new to ASP.Net using C#. I want to do a printer friendly page and my system should change the printer orientation to landscape automatically by default. The content includes images and text. I only want to show the content. How can I do this?
-
@Michael well, I'd say we've corrected every error that could possibly be in this question :) – Earlz Mar 21 '11 at 02:00
-
Also, @jenny, do you use master pages then? I have a feeling you'd need to completely make a different page from your regular "web" page. This is a lot easier if you followed some separation between the view(markup) and the domain logic – Earlz Mar 21 '11 at 02:02
-
@Earlz: there's always more... to haunt me in the middle of the night... – Michael Petrotta Mar 21 '11 at 02:02
2 Answers
You should take a look at CSS for creating print-friendly pages:
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
When you set the media="print"
attribute, you're telling the browser to use that particular stylesheet instead of the regular one. There's a great article on CSS and print on A List Apart, "CSS Design: Going to Print" by Eric Meyer.
And specifically for the landscape page orientation, try this in your CSS:
@page { size: landscape }
Update: Daniel Ballinger was kind enough to point out the size: landscape
attribute isn't supported in the majority of current browsers (if any).

- 1
- 1

- 12,319
- 15
- 70
- 118
-
I've had little luck in setting landscape printing through CSS. See also - http://stackoverflow.com/questions/4249532/is-page-sizelandscape-obsolete – Daniel Ballinger Mar 21 '11 at 02:28
You could try using CSS definitions that actively target printer output using print media. This will allow you to hide or show elements as required.
This can be done with either a reference to a separate style sheet or by using an @media rule within the existing style definitions.
Specify the target medium within the document language
<LINK REL="stylesheet" TYPE="text/css" MEDIA="print" HREF="print.css">
Specify the target medium from a style sheet with the @media or @import at-rules.
@import url("print.css") print;
or
@media print {
/* style sheet for print goes here */
}
I've looked at changing the print orientation in the past and the conclusion I came to was that was outside your ability to control in a website. I.e. there was no solution that worked well for the majority of browsers. See also Is @Page { size:landscape} obsolete?

- 1
- 1

- 13,187
- 11
- 69
- 96