Change the page orientation in middle of doc

妖精的绣舞 提交于 2019-12-07 14:24:57

问题


I need to set landscape to some pages of a document. I tried this code:

    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);

It creates this xml code:

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

And after of the Section tag have the text and the table that i need inside landscape page. With Word 2007/2010 i only see the portrait page and in editing mode of the page I can see the page selected as landscape.

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


回答1:


The sectPr should be in a w:p/w:pPr after the content which it is to appear in landscape orientation.

You need sectPr specifying portrait before that content.



来源:https://stackoverflow.com/questions/14983913/change-the-page-orientation-in-middle-of-doc

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