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(...)