POIFSFileSystem导出word增加横向打印

在jsp中引用response.setContentType("application/msword");,打开的页面就是word样式。

1、实现word横打:


<style>
@page
 {mso-page-border-surround-header:no;
 mso-page-border-surround-footer:no;}
@page print-section1
 {size:841.9pt 595.3pt; //A4纸张的大小
 mso-page-orientation:landscape;
 margin:89.85pt 72.0pt 89.85pt 72.0pt;
 mso-header-margin:42.55pt;//页眉
 mso-footer-margin:49.6pt;//页脚
 mso-paper-source:0;
 layout-grid:15.6pt;}
div.print-section1
 {page:print-section1;}
</style>
然后在html中将打印内容包裹在div当中就可以实现了:



<div class="print-section1"></div>
2、自定义纸张大小纵打



<style>
@page
 {mso-page-border-surround-header:no;
 mso-page-border-surround-footer:no;}
@page Print-Section1
 {size: 21.5cm 14.00cm;
 margin-left:0.5cm;//左页边距
 margin-right:0.5cm;//右页边距
 margin-top:0.5cm;//上页边距
 margin-bottom:0.5cm//下页边距;
 mso-header-margin:0.5cm;
 mso-footer-margin:0.5cm;
 layout-grid:0.5pt;}
div.print-section1
 {page:print-section1;}
</style>



您可能还会对下面的文章感兴趣: