以横向格式打印 [英] Print in Landscape format
问题描述
可能重复:
从HTML进行横向打印
我正在使用以下代码在单击按钮时显示打印窗口:
I am using below code to show print window on button click:
function print_onclick() {
window.print();
return false;
}
我希望页面以横向格式打印.我可以在上面的代码中添加任何属性以使其正常工作吗?
I want the page to be printed in Landscape format. Is there any property I can add in above code to make it work ?
其他信息:因为我的页面宽度是1280像素,所以当我在纵向打印A4纸上时,字体变得太小.我只想打印2行.如果不是横向格式,是否可以在打印时固定那些表格单元格/div的字体大小?
Additional Info: Since my page width is 1280 px, when I print it on A4 paper with portrait orientation, the font becomes too small. I want to print only 2 lines. If not landscape, is there a way I can fix the font size of those table cell/divs while printing ?
推荐答案
您无法在javascript中进行设置,而必须使用html/css进行此操作:
you cannot set this in javascript, you have to do this with html/css:
<style type="text/css" media="print">
@page { size: landscape; }
</style>
有关浏览器支持的更多信息,请参见此问题和可接受的答案:是@Page {size:landscape}过时了?
See this Question and the accepted answer for more information on browser support: Is @Page { size:landscape} obsolete?
这篇关于以横向格式打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!