首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >apache odftoolkit纵向/横向模式

apache odftoolkit纵向/横向模式
EN

Stack Overflow用户
提问于 2017-10-05 15:46:46
回答 2查看 141关注 0票数 1

我正在使用库apache生成从odftoolkit代码到*.odt文件的报告。代码如下:

代码语言:javascript
复制
outputOdt = TextDocument.newTextDocument();
Paragraph p = outputOdt.addParagraph("some text");
p.appendTextContent("some text");

我正在添加段落,表格,设置字体,它工作得很好。但我需要在横向模式下设置文档中的一些页面,但不知道如何执行此操作。我找到了API类PageLayoutProperties和方法setPrintOrientation(),但不知道在哪里调用它。有人知道吗?

EN

回答 2

Stack Overflow用户

发布于 2018-10-03 19:51:49

找到解决方案:

代码语言:javascript
复制
TextDocument outputOdt;
for( Iterator<StyleMasterPageElement> it = outputOdt.getOfficeMasterStyles().getMasterPages(); it.hasNext(); ) {
            StyleMasterPageElement page = it.next();
            String pageLayoutName = page.getStylePageLayoutNameAttribute();
            OdfStylePageLayout pageLayoutStyle = page.getAutomaticStyles().getPageLayout( pageLayoutName );
            PageLayoutProperties pageLayoutProps = PageLayoutProperties.getOrCreatePageLayoutProperties( pageLayoutStyle );

            double tmp = pageLayoutProps.getPageWidth();
            pageLayoutProps.setPageWidth( pageLayoutProps.getPageHeight());
            pageLayoutProps.setPageHeight( tmp );
        }
票数 0
EN

Stack Overflow用户

发布于 2019-02-07 18:59:51

我遇到了这个现有的问题和答案:

How can the Page Size, Page Orientation, and Page Margins of an ods Spreadsheet Be Set Using ODFDOM?

这是关于对ODS电子表格做同样的事情,本质上是相同的。关键是在PageLayoutProperties中设置页面的高度和宽度以及打印方向

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46580464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档