Style Sheets for Printing
Hi all,
I've since found out about the Media='Print' call for style sheets and want to use this for a printer friendly page.
I've managed to get rid of the things i don't want to show on the printed copy but i have one major problem which i hope someone can help with.
I want to display a datagrid on the printed form. This datagrid is however slightly to big on screen to fit onto an A4 page. How would i go about resizing/rescaling to fit the page from right to left. I also know that it will be possible to roll over onto multiple pages and i'd also like to find out how to do this without chopping text in half.
This sounds easy, but I can find nothing that has proved any help to me as yet.
Hopefully someone can help on this matter.
Many thanks in advance.
Grant
Re: Style Sheets for Printing
There are a couple of things you could do. One is to try printing the page in landscape orientation.
Code:
@page
{
size: landscape;
}
Unfortunately it seems this is only supported by Opera. Special print rules generally seem to be pretty badly supported by all the browsers. There are also a few more rules that are interesting: page-break-after, page-break-before, page-break-inside, but I don't think any browser supports them.
Now, scaling. There is no scale property as such so what you would have to do to shrink an object is reduce things like font size, padding, margins, etc.
If that doesn't help can you post a screenshot or just a diagram of what you need shrinking?
Re: Style Sheets for Printing
Ok,
Thanks for getting back to me. I discovered that because the Datarid width was being set in the properties as apposed to in a Screen style sheet, when i attempted to change the widt for the print style sheet it was not happening. I have since changed how i set the width so i now use the style sheet. The sorts the horizontal layout problem.
I now need to find how to output data so that a new row of the datagrid is never halved between pages (hence beginning a new page if this was to occur. Any ideas on this?
Many thanks for your patience.
Re: Style Sheets for Printing
Correction,
I have the pagebreak stuff now working to an extent. The only problem is that when it inserts a page break it doesn't necessarily do it after each row. If the row has sections which cover mulitiple lines (Which is likely) the page break sometimes appears mid row splitting the text between two pages. Is there any way to get around this?
Cheers
Re: Style Sheets for Printing
Theoretically, this
Code:
.datagrid-row /* replace with class name of row */
{
page-break-inside: never;
}
should do it. But like I said in practice I don't think any browser supports that properly.
Re: Style Sheets for Printing
Ah, theory. A place i'd like to go where everything works :)
Unfortunately, in this case you're quite right, it doesn't work in practice with IE. I may just have to leave it with the possibility of rows being split.
Thanks for your help, its appreciated.