Hy,
I have a problem when appending 2 documents. A document with no header will get one after appending, the header added is empty but that still create a margin at the top of the printed final document.
Here is my method :
public static Document appendDoc(Session session, com.aspose.words.Document dstDoc, com.aspose.words.Document srcDoc, boolean rebuildPagination) {
try{
if (dstDoc == null) {
dstDoc = srcDoc;
replaceNumpageByNumpageinsection(session, dstDoc);
}else{
if (rebuildPagination) {
for (int i = 0; i
Section srcSection = srcDoc.getSections().get(i);
srcSection.getPageSetup().setSectionStart(SectionStart.NEW_PAGE);
Section dstSection = (Section) dstDoc.importNode(srcSection, true, ImportFormatMode.USE_DESTINATION_STYLES);
dstDoc.appendChild(dstSection);
dstSection.getHeadersFooters().linkToPrevious(false);
dstSection.getPageSetup().setPageStartingNumber(1);
dstSection.getPageSetup().setRestartPageNumbering(true);
HeaderFooter footer = dstSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);
if (footer != null) {
footer.isLinkedToPrevious(false);
}
HeaderFooter header = dstSection.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
if (header != null) {
header.isLinkedToPrevious(false);
}
for (Object p : dstSection.getChildNodes(NodeType.PARAGRAPH, true)) {
((Paragraph) p).getParagraphFormat().setWidowControl(true);
}
}
} else {
appendDoc(session,dstDoc, srcDoc);
}
}
}catch(Exception ex){
logger.logException(session, Lab4Level.ERROR, “appendDoc”, ex);
}
return dstDoc;
}
Have you got any clue how to solve my problem ?
I join 2 docs, the first one has no header.
Thanks a lot,
Yoann TAS
Hi Yoann,
Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:
- Please attach the output Word file that shows the undesired behavior.
- Please attach the expected output Word file that shows the desired behavior.
- Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.
As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.
PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.