增加横向页眉页脚模板\根据页面排版插入页眉页脚
This commit is contained in:
parent
d11a4a3dca
commit
efd81e5eb5
Binary file not shown.
@ -827,41 +827,61 @@ public class InstitutionalTextWeb extends ActionWeb {
|
||||
|
||||
//加载文档2
|
||||
com.sini.com.spire.doc.Document doc2 = new com.sini.com.spire.doc.Document();
|
||||
|
||||
|
||||
doc2.loadFromFile(outFile.getPath());
|
||||
|
||||
|
||||
SectionCollection sections = doc2.getSections();
|
||||
|
||||
|
||||
//加载文档1
|
||||
com.sini.com.spire.doc.Document doc3 = new com.sini.com.spire.doc.Document();
|
||||
doc3.loadFromFile(tempPath + "横板页眉页脚模板.doc");
|
||||
|
||||
// 获取源文档的页眉页脚
|
||||
Section sourceSection = doc1.getSections().get(0);
|
||||
/*Section sourceSection = doc1.getSections().get(0);
|
||||
HeaderFooter sourceHeader = sourceSection.getHeadersFooters().getHeader();
|
||||
HeaderFooter sourceFooter = sourceSection.getHeadersFooters().getFooter();
|
||||
HeaderFooter sourceFooter = sourceSection.getHeadersFooters().getFooter();*/
|
||||
|
||||
// 将页眉复制到目标文档的第三节以及后续节
|
||||
for (int i = 0; i < doc2.getSections().getCount(); i++) {
|
||||
for (int i = 2; i < doc2.getSections().getCount(); i++) {
|
||||
Section targetSection = doc2.getSections().get(i);
|
||||
|
||||
PageSetup pageSetup = targetSection.getPageSetup();
|
||||
PageOrientation orientation = pageSetup.getOrientation();
|
||||
|
||||
|
||||
// 根据合并文档节的页面方向选择模板
|
||||
PageOrientation mergeOrientation = pageSetup.getOrientation();
|
||||
com.sini.com.spire.doc.Document templateDoc = (mergeOrientation == PageOrientation.Landscape) ? doc3 : doc1;
|
||||
|
||||
// 复制模板文档的页眉和页脚到新文档
|
||||
HeaderFooter sourceHeader = templateDoc.getSections().get(0).getHeadersFooters().getHeader();
|
||||
|
||||
HeaderFooter targetHeader = targetSection.getHeadersFooters().getHeader();
|
||||
targetHeader.getChildObjects().clear();
|
||||
|
||||
for (int j = 0; j < sourceHeader.getChildObjects().getCount(); j++) {
|
||||
|
||||
DocumentObject obj = sourceHeader.getChildObjects().get(j).deepClone();
|
||||
targetHeader.getChildObjects().add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
// 将页脚复制到目标文档的第三节以及后续节
|
||||
for (int i = 0; i < doc2.getSections().getCount(); i++) {
|
||||
for (int i = 2; i < doc2.getSections().getCount(); i++) {
|
||||
Section targetSection = doc2.getSections().get(i);
|
||||
HeaderFooter targetFooter = targetSection.getHeadersFooters().getFooter();
|
||||
|
||||
PageSetup pageSetup = targetSection.getPageSetup();
|
||||
|
||||
PageOrientation mergeOrientation = pageSetup.getOrientation();
|
||||
com.sini.com.spire.doc.Document templateDoc = (mergeOrientation == PageOrientation.Landscape) ? doc3 : doc1;
|
||||
HeaderFooter sourceFooter = templateDoc.getSections().get(0).getHeadersFooters().getFooter();
|
||||
|
||||
targetFooter.getChildObjects().clear();
|
||||
for (int j = 0; j < sourceFooter.getChildObjects().getCount(); j++) {
|
||||
DocumentObject obj = sourceFooter.getChildObjects().get(j).deepClone();
|
||||
targetFooter.getChildObjects().add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
doc2.saveToFile(outFile.getPath(), FileFormat.Docx_2013);
|
||||
|
||||
|
||||
|
||||
@ -2739,7 +2739,7 @@ y7fdOgAAAABJRU5ErkJggk==
|
||||
</w:pPr>
|
||||
</w:p>
|
||||
</wx:sect>
|
||||
<wx:sect>
|
||||
<!--<wx:sect>
|
||||
<w:p wsp:rsidR="002737AF" wsp:rsidRDefault="002737AF" wsp:rsidP="00F96B41">
|
||||
<w:pPr>
|
||||
<w:rPr>
|
||||
@ -2765,7 +2765,7 @@ y7fdOgAAAABJRU5ErkJggk==
|
||||
</w:sectPr>
|
||||
</w:pPr>
|
||||
</w:p>
|
||||
</wx:sect>
|
||||
</wx:sect>-->
|
||||
<wx:sect>
|
||||
<wx:sub-section>
|
||||
<w:p wsp:rsidR="002737AF" wsp:rsidRDefault="002737AF" wsp:rsidP="00F96B41">
|
||||
|
||||
BIN
com.awspaas.user.apps.coe.pal.output.zd/横板页眉页脚模板.doc
Normal file
BIN
com.awspaas.user.apps.coe.pal.output.zd/横板页眉页脚模板.doc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user