Concatenate files at the same page

I am using this code to concatenate files one after the other separated by a paragraph, but the header and footer are missing in the generated file. How to fix that?

        Document dstDoc = new Document();
        dstDoc.removeAllChildren();
        Document srcDoc = null;
        boolean firstDoc = true;
        DocumentBuilder builder = new DocumentBuilder(dstDoc);

        for (String fileName : fileNames) {
            srcDoc = new Document(fileName);

            if (firstDoc) {
                builder.getFont().setSize(new DocumentBuilder(srcDoc).getFont().getSize());
                builder.insertDocument(srcDoc, ImportFormatMode.USE_DESTINATION_STYLES);
                firstDoc = false;
            } else {
                builder.insertParagraph();
                builder.insertDocument(srcDoc, ImportFormatMode.USE_DESTINATION_STYLES);
            }
        }

        dstDoc.save(...)

@cpatricio76

Thanks for your inquiry. Please check following documentation link to keep the Header and Footer of source document. Hopefully it will help you to accomplish the task. However, if the issue persists then please share your sample input documents along with output document as ZIP file here. We will look into these and will guide you accordingly.

Stopping Headers and Footers from continuing from the destination document