3

我需要为文档的某些页面设置横向。我试过这段代码:

    SectPr sectionLandscape = objectFactory.createSectPr();

String rsidR = sectionLandscape.getRsidR();     

SectPr sectionPortrait = objectFactory.createSectPr();
sectionPortrait.setRsidR(rsidR);
sectionPortrait.setRsidSect(rsidR);    

PgSz landscape = new PgSz();
landscape.setOrient(STPageOrientation.LANDSCAPE);
landscape.setH(BigInteger.valueOf(11906));
landscape.setW(BigInteger.valueOf(16383));       

sectionLandscape.setPgSz(landscape);

mdp.addObject(sectionLandscape);

它创建这个 xml 代码:

<w:sectPr>
    <w:pgSz w:w="16383" w:orient="landscape" w:h="11906"/>
</w:sectPr>

在 Section 标记之后有我在横向页面中需要的文本和表格。使用 Word 2007/2010,我只能看到纵向页面,在页面的编辑模式下,我可以看到选择为横向的页面。

http://i.stack.imgur.com/HHuGB.png

4

1 回答 1

2

sectPr 应该在横向显示的内容之后的 aw:p/w:pPr 中。

您需要 sectPr 在该内容之前指定肖像。

于 2013-02-20T20:23:03.410 回答