最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to customize the printing while using Window.print? - Stack Overflow

programmeradmin4浏览0评论

i want to print a invoice and i use a print.css by media=print and when i change the current stylesheet to print.css i could able to view what i should be printing without the titles and content left aligned.

But still while i'm printing there is space in the top and left and its taking up whole a4 sheet and also the whole width of the page.. But i've defined a body width of just 550 px.

While i view to print preview, it takes the whole width instead of taking up 1/3 of the width..

My print.css is

body {
  width:550px;
  height:450px;
  color:#000000;
  margin:0;
  padding:0;
  word-spacing:1.1pt;
  font-family : "Times New Roman", Times, serif;
  font-size : 10px;
  text-align:left; 
}

a {
  visibility :hidden;
  display : none;  
}

input{
  display : none;  
}

table { margin: 1px; text-align:left; }

#list,#head,#cont,#fotter,#oth,#links,#name,li,ul,ol {
  display : none;  
}

I'm printing through browser using window.print, so is there any special configuration i need to do...?

i want to print a invoice and i use a print.css by media=print and when i change the current stylesheet to print.css i could able to view what i should be printing without the titles and content left aligned.

But still while i'm printing there is space in the top and left and its taking up whole a4 sheet and also the whole width of the page.. But i've defined a body width of just 550 px.

While i view to print preview, it takes the whole width instead of taking up 1/3 of the width..

My print.css is

body {
  width:550px;
  height:450px;
  color:#000000;
  margin:0;
  padding:0;
  word-spacing:1.1pt;
  font-family : "Times New Roman", Times, serif;
  font-size : 10px;
  text-align:left; 
}

a {
  visibility :hidden;
  display : none;  
}

input{
  display : none;  
}

table { margin: 1px; text-align:left; }

#list,#head,#cont,#fotter,#oth,#links,#name,li,ul,ol {
  display : none;  
}

I'm printing through browser using window.print, so is there any special configuration i need to do...?

Share Improve this question asked Jun 2, 2010 at 5:15 VijayVijay 5,42310 gold badges56 silver badges88 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Unfortunatley there's nothing you can do whilst using window.print (or any other JavaScript method).

The only way to get your page to print the way you want is to select File > Print Preview and then configure any layout settings there. For example, on Firefox you can make the webpage stretch across a single sheet of A4.

发布评论

评论列表(0)

  1. 暂无评论