问题
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