I've been working with a css file to produce a few bits of needful output formatting for some php-built reports that are designed to be printed from the web. Recently, though, on one of our systems, I had an incident where it looked as though part of the css was either not processing, or was getting mislaid on the way.

The statement in question is

@page

{
    size landscape;
}

, a CSS2 instruction that is supposed to format the page in landscape orientation for printing purposes. The nature of my reports (rather wide layout) means that I need to be able to print them landscape if possible. This instruction isn't supported by every browser (notably, IE doesn't seem to support it), but the Firefox browsers we use inhouse do seem to do so.

Recently, though, I had to transfer one of my report-generating programs to another box in order to show the boss what I've got done so far. Both this system and my dev box are running Windows XP. Both of them have Firefox on them, version 1.5.0.12.

On my dev box, the CSS2 instruction works; printing the web report automatically prints it in landscape version. On the other box, when the report opened in Firefox, printing it caused it to come out in portrait orientation until my boss manually swapped the layout.

I don't know anything about why this might have happened. Would someone mind please giving me some kind of pointers to possible causes, or to areas of possible difference on the two systems I should be taking a look at?

Thank you for your consideration.

Dani AI

Generated

Short summary: the CSS paged-media rule used for controlling print orientation is implemented differently across browser versions and can be ignored by the printing subsystem (browser + driver). Confirm whether the rule is actually reaching and being parsed by the Firefox instance on the problem machine, then narrow down whether the browser or the printer driver is taking precedence. For authoritative references see the MDN page on the @page rule and the W3C paged-media spec: MDN: @page and W3C CSS Paged Media — size.

Practical troubleshooting (ordered, quick checks):

  • Load the stylesheet directly in the browser and clear caches to ensure the same file is used on both machines.
  • Reproduce with a tiny test page and print there first; use a generic "print to PDF" target to remove printer-driver variables.
  • Run Firefox in Safe Mode or a fresh profile to rule out extensions or per-profile print prefs interfering.
  • Open the browser Error Console for CSS parse warnings and inspect printing-related preferences via about:config (search for keys starting with print.) and compare values between machines.

How to interpret results:

  • If the rule is not present or the console shows parse errors: fix the stylesheet (validator: W3C CSS Validator).
  • If the rule exists but orientation is still overridden when printing to a physical printer: the printer driver or OS default is likely overriding browser requests. Updating the driver or testing with another printer/PDF driver will reveal that.
  • If behavior differs only on one machine, focus on that machine's profile, installed add-ons, and its about:config print settings.

Notes: raised the importance of syntax/valid CSS; pointed toward printer/permission differences — the steps above show how to dig deeper than those starting points and isolate browser vs driver vs profile causes.

Recommended Answers

All 2 Replies

Okay - never tried... but after a little research....

1) Try using : after size ?
You have put "size landscape;"... try "size: landscape;" instead

2) Try it on a Single line.
@page {size: landscape;}

3) For Reference - 1...

4) For Reference - 2...


Hope that helps.

Do you have the same printer?

Some print drivers ignore such operations.

Are the browsers configured for the same security settings?

Some browsers have settings to deny permission for such operations.

I consider such a style to be a security violation. Those settings on my computer are mine, not the property of some web author.

Why not just put instructions on the page to open the file menu and change the print setting to landscape? It will go away when the browser closes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.