开发者

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 bl开发者_高级运维ock 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜