views:

44

answers:

2

Hi

I'm creating a invoice and have option to print the invoice. While printing i use a stylesheet (using media=print) to block the display of elements which should not be printed...

But while printing it takes the full size of the window and uses that much paper..

I want to restrict the size of the printing area.... How can i do that?

A: 

Customizing a page for printing can be difficult with CSS because of browser restrictions. The best way I've found to do what you're asking is to set margins on the body to position the HTML on the printed page.

Steven Paligo
Can you please be more elaborate? For example if i have just two rows of data i want them to be printed as it is and should not take up a height of a a4 sheet
kvijayhari
+1  A: 

Hi Holicreature,

Without seeing the CSS on the original page I can't really be sure, but make sure you are using display:none rather than visibility:hidden to remove the areas you don't want to print.

If you have any widths set on the body or containing elements you could try removing/reseting them.

Or maybe have a look at some CSS print frameworks such as hartija http://code.google.com/p/hartija/

Good luck,

Jedidiah


edit: Just read your comment to Steven Paligo. If the rows are in a table could you try setting a fixed or maximum height on the TR.

Jedidiah
Yes. i have used the display:none property for the elements but my problem is mainly on controlling the width and height of the printed area. I want the things to be printed on a paper of approximately 300px width and if my printing is content is just 500px height then i want that much paper to be used, instead the window height is taken as the height..
kvijayhari