Problem with Section Properties and Header/Footer
Posted: Sun Sep 09, 2012 2:01 am
Hello,
I'm creating a docx document with a lot of text and a table at the end of the document. The pages with the text should be in "portait" format and the table in "landscape" format. The orientation thing is not my problem- it works fine. But I also have header and footer in my document and since I add the change in the oriantation they disappeared.
I add the "landscaped" table like this:
I generated this code according to the xml I saw in my test docx (which i created in the way the document should look like). Please see the attachmend for this file.
I create a P like that:
-<w:p w:rsidRDefault="00E6608B" w:rsidR="00E6608B">-<w:pPr>-<w:sectPr w:rsidR="00E6608B" w:rsidSect="00E6608B"><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:gutter="0" w:footer="708" w:header="708" w:left="1417" w:bottom="1134" w:right="1417" w:top="1417"/><w:cols w:space="708"/><w:docGrid w:linePitch="360"/></w:sectPr></w:pPr></w:p>
add the table to the document
and add the sectPr similar like this:
-<w:sectPr w:rsidR="00267409" w:rsidSect="00E6608B"><w:pgSz w:w="16838" w:h="11906" w:orient="landscape"/><w:pgMar w:gutter="0" w:footer="709" w:header="709" w:left="1134" w:bottom="1418" w:right="1418" w:top="1418"/><w:cols w:space="708"/><w:docGrid w:linePitch="360"/></w:sectPr>
But why are my header and footer gone? The footer and header worked fine before...
If there are any further documents or code you need, just let me know.
I'm creating a docx document with a lot of text and a table at the end of the document. The pages with the text should be in "portait" format and the table in "landscape" format. The orientation thing is not my problem- it works fine. But I also have header and footer in my document and since I add the change in the oriantation they disappeared.
I add the "landscaped" table like this:
- Code: Select all
public boolean add(WordTable wTable, boolean vertical){
if(wTable == null) return false;
if(!vertical) return add(wTable);
SectPr sectionLandscape = objectFactory.createSectPr();
//dieser Wert werden als referenz auf das Format benoetigt
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));
PgSz portrait = new PgSz();
portrait.setOrient(STPageOrientation.PORTRAIT);
portrait.setH(BigInteger.valueOf(16383));
portrait.setW(BigInteger.valueOf(11906));
sectionLandscape.setPgSz(landscape);
sectionPortrait.setPgSz(portrait);
P p1 = objectFactory.createP();
PPr pPr = objectFactory.createPPr();
pPr.setSectPr(sectionPortrait);
p1.setRsidR(rsidR);
p1.setRsidRDefault(rsidR);
p1.setPPr(pPr);
mainDocumentPart.addObject(p1);
mainDocumentPart.addObject(wTable.getDocx4jTable());
mainDocumentPart.addObject(sectionLandscape);
return true;
}
I generated this code according to the xml I saw in my test docx (which i created in the way the document should look like). Please see the attachmend for this file.
I create a P like that:
-<w:p w:rsidRDefault="00E6608B" w:rsidR="00E6608B">-<w:pPr>-<w:sectPr w:rsidR="00E6608B" w:rsidSect="00E6608B"><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:gutter="0" w:footer="708" w:header="708" w:left="1417" w:bottom="1134" w:right="1417" w:top="1417"/><w:cols w:space="708"/><w:docGrid w:linePitch="360"/></w:sectPr></w:pPr></w:p>
add the table to the document
and add the sectPr similar like this:
-<w:sectPr w:rsidR="00267409" w:rsidSect="00E6608B"><w:pgSz w:w="16838" w:h="11906" w:orient="landscape"/><w:pgMar w:gutter="0" w:footer="709" w:header="709" w:left="1134" w:bottom="1418" w:right="1418" w:top="1418"/><w:cols w:space="708"/><w:docGrid w:linePitch="360"/></w:sectPr>
But why are my header and footer gone? The footer and header worked fine before...
If there are any further documents or code you need, just let me know.