Extra sections getting added when appending documents

I have a document and need to append another document to it.



I’m using this method



public void appendDocumentNode(Document dstDoc, Document srcDoc) throws Exception

{

srcDoc.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);



for (Object section : srcDoc)

{

if(dstDoc.getLastSection() == null)

{

     Node dstSection =

dstDoc.importNode(section, true,

ImportFormatMode.USE_DESTINATION_STYLES);


     dstDoc.appendChild(dstSection);<br>
            }<br>
       
else 

dstDoc.getLastSection().appendContent(section);

}

}



Two extra sections are being added between the two documents. I
need to keep the sections on each document intact because I need to
preserve the headers and footers.



Is there anyway to avoid adding the extra section breaks?



Thanks


Hi,

Please also attach the source and destination documents so that we could test them.