I'm having a bit of trouble figuring something out. I have a css file I use to attempt to break pages in the correct spot, and to force a landscape print so as to ensure that the words on the web reports my php program builds aren't packed together when printed out. The following is a complete copy of the text of the css file I use to
do this-

p { page-break-before: always;}
@page

{
    size landscape;
}

The css file is called from my program with the following command-

echo '<link rel="stylesheet" type="text/css" href="cancelheader.css"/>';

For some reason, I'm now having trouble getting this to work on a new program. As far as I can tell, the only differences are that a) the new program includes others that also make use of the page-break function, and b) the new files are in a different directory from the original css file. A copy of the css file has been placed in this directory, however.

Before, I've always used a single php file; now, I've got three separate files that get called from a single higher one. With this program, I cannot get the pagebreaks to occur when they are supposed to according to the css file.

I have tried the following to attempt to solve this:
1) Each of the original files included the reference to the css file. I commented those out, leaving instead a single copy in the higher-level file that calls(includes) them. This has not helped. Even a <p/> tag within the higher-level file does not break the way it should.
2) I tried to clear the cache, in hopes of solving the problem that way. This has not worked.
3) I closed down all browser windows (I thought this only applied to sessions, but I wanted to make certain) then opened up a new one and loaded the page again. This did not work.

I am using Firefox, version 1.5.0.12, to load the page.

Does anyone have any suggestions what my problem here might be, or solutions as to other things I can try to solve it?

Recommended Answers

All 8 Replies

erm...tricky are you sure your href is going to the right file and doesnt need jumping in or out (../)???

There is a copy of the .css file in the same directory as the files that are calling it.

I cant see anything wrong with your code and the placing of it, nor your browser and anything else??? sorry im confused at this one.

The choice of portrait or landscape printing belongs to the owner of the computer browsing your page, not to you.

@MidiMagic:
In this case, the choice belongs to my boss, who tells me what needs to be put on the page, that the results have to be printable from the browser to paper, and that the page needs to be made to look neat on paper. Unless the browser's going to shrink the results for me, these aren't compatible with portrait formatting. Too many items.

@Thread:
Found the problem...simple PEBKAC error in the code. I'd somehow forgotten to close off a set of table tags.

But your boss can't override internet security, or the law, or the limitations of the hardware attached to the computer.

That choice is the PROPERTY of the user. It belongs to him, because his computer belongs to him. Those settings are permanently part of his computer, not your web page. They are in his printer driver, not part of the browser or the web page. When you make that choice in the browser's FILE menu, you are really talking to the printer driver, and using the printer driver's own dialog box.

Also note that some printer drivers do not HAVE a landscape setting, because the printer can't DO landscape. You can't assume that everyone has a LaserJet or a Lexmark. A relative's computer still has a daisy-wheel printer. The "landscape" mode requires her to physically move the paper guides, put the paper in sideways, and select "landscape 11 X 8.5 paper" from the paper choices. There is no way to just select "landscape" on that computer and have it work.

Your boss can blow his little top off, with steam coming out his ears, but he can't change the law, the rules of internet security, or the limitations of the user's computer hardware. So you should have a camera ready, so you can photograph the steam when he finds these things out.

If you do find a way to do this, you could be violating federal law. And if you were ordered to crack into the user's computer so the boss can have his way, then the boss can be charged too.

The only right way to do this is to ASK the user to change his settings to landscape before printing the page.

I am not assuming that everyone can do this, MidiMagic. I am assuming that a specific individual, one of the upper-level staff for the company that retains my own for its IT purposes, when using an internal business form, has access to at least one business printer that can do this, and to a browser that can parse and use the CSS2 tag. Failing the tag, there won't be any changes and the system will print out in portrait style. I don't have to break into the other system, merely to have a specific piece of pre-defined CSS2 code in place in my own .css file. I fail to see how that violates the law.

Or are you somehow suggesting that the CSS2 code itself is illegal? I'll be happy to bring the topic up in the Geek's Lounge for discussion if that is the case.

An intranet is different. But you didn't say anything about that.

I was thinking of an advertising page where your boss wanted to change the printer settings of every user who accesses the advertising page. That would be illegal cracking

Although a CSS tag which selects landscape for just the one print job is a great idea, provided the printer can actually do landscape. It doesn't permanently change the settings.

If you are doing print to a network printer, you can put this in the settings for the network printer.

I have had too many trials in the past where I had a special printer set up, with special values in the driver registers, and then the application software comes along and resets the printer driver to "standard", destroying the settings necessary to use that printer. Or their reset destroyed the offset of the tractor-feed paper in use.

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.