Vijay
Vijay

Reputation: 5433

How to fix the size of the printing area while using window.print?

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?

Upvotes: 1

Views: 3157

Answers (2)

Jedidiah
Jedidiah

Reputation: 1194

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.

Upvotes: 2

Steven P.
Steven P.

Reputation: 939

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.

Upvotes: 0

Related Questions