admin管理员组文章数量:1022944
In a web application for an intranet, I have a webpage that has to be printed by the user in legal (8 1/2" x 14") paper.
Is there a way using CSS or JavaScript to tell the browser to request (or optimize) for this paper size? If there isn't, is it possible to at least change the default printer settings for this particular webpage so the user doesn't have to specify Legal Paper manually?
Thanks in advance for your kind answers.
In a web application for an intranet, I have a webpage that has to be printed by the user in legal (8 1/2" x 14") paper.
Is there a way using CSS or JavaScript to tell the browser to request (or optimize) for this paper size? If there isn't, is it possible to at least change the default printer settings for this particular webpage so the user doesn't have to specify Legal Paper manually?
Thanks in advance for your kind answers.
Share Improve this question asked Feb 18, 2013 at 20:16 MeryoviMeryovi 6,2315 gold badges43 silver badges67 bronze badges 3-
Whenever I see the word "force" in a requirement the first thing I think is:
You're doing it wrong.
– Joel Etherton Commented Feb 18, 2013 at 20:20 - In this case I can assure you I'm not doing it wrong and it is an actual requirement. – Meryovi Commented Feb 19, 2013 at 3:07
- You missed my meaning. The message was aimed at the requirement. In most cases, when the requirement is designed to "force the user", it's a pointer that there is probably something wrong with the requirement, not the code. – Joel Etherton Commented Feb 19, 2013 at 3:43
3 Answers
Reset to default 3This can't be done with standard CSS or JavaScript. You might be able to do this with ActiveX but I can't say that for sure and even then it will only work in IE.
If this can't be achieved via CSS/JS, an alternative would be to dynamically generate a PDF that is legal size from the HTML. There are plenty of HTML to PDF converters, one of the best open source options is mPDF
You can try CSS and see if that will work for you. It seems to work with a few of my printers, but not all.
@media print {
body {
width:816px;
height:1344px;
}
In a web application for an intranet, I have a webpage that has to be printed by the user in legal (8 1/2" x 14") paper.
Is there a way using CSS or JavaScript to tell the browser to request (or optimize) for this paper size? If there isn't, is it possible to at least change the default printer settings for this particular webpage so the user doesn't have to specify Legal Paper manually?
Thanks in advance for your kind answers.
In a web application for an intranet, I have a webpage that has to be printed by the user in legal (8 1/2" x 14") paper.
Is there a way using CSS or JavaScript to tell the browser to request (or optimize) for this paper size? If there isn't, is it possible to at least change the default printer settings for this particular webpage so the user doesn't have to specify Legal Paper manually?
Thanks in advance for your kind answers.
Share Improve this question asked Feb 18, 2013 at 20:16 MeryoviMeryovi 6,2315 gold badges43 silver badges67 bronze badges 3-
Whenever I see the word "force" in a requirement the first thing I think is:
You're doing it wrong.
– Joel Etherton Commented Feb 18, 2013 at 20:20 - In this case I can assure you I'm not doing it wrong and it is an actual requirement. – Meryovi Commented Feb 19, 2013 at 3:07
- You missed my meaning. The message was aimed at the requirement. In most cases, when the requirement is designed to "force the user", it's a pointer that there is probably something wrong with the requirement, not the code. – Joel Etherton Commented Feb 19, 2013 at 3:43
3 Answers
Reset to default 3This can't be done with standard CSS or JavaScript. You might be able to do this with ActiveX but I can't say that for sure and even then it will only work in IE.
If this can't be achieved via CSS/JS, an alternative would be to dynamically generate a PDF that is legal size from the HTML. There are plenty of HTML to PDF converters, one of the best open source options is mPDF
You can try CSS and see if that will work for you. It seems to work with a few of my printers, but not all.
@media print {
body {
width:816px;
height:1344px;
}
本文标签: javascriptForce webpage to print in legal paperStack Overflow
版权声明:本文标题:javascript - Force webpage to print in legal paper - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745523064a2154404.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论