Apache POI. How do I set the page layout / paper size for a Word document?

↘锁芯ラ 提交于 2019-12-13 03:35:21

问题


I am trying to create a Word document from scratch using the Apache POI package. Outputting simply-formatted text has not proved to be a problem but I would like to change the page size.

How do I set the page layout / paper size for a Word document?

Can anyone point me to useful examples for using POI to create Word documents?


回答1:


For example if you want to set the A4-format you can use this code:

 Document document = new Document(PageSize.A4);



回答2:


In C# with NPOI I use

document.PageLayout.Orientation = Orientation.Landscape;

or

document.PageLayout.Orientation = Orientation.Portrait;


来源:https://stackoverflow.com/questions/2849809/apache-poi-how-do-i-set-the-page-layout-paper-size-for-a-word-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!