Add header and footer to the output document if not already present

This commit is contained in:
Adam Goldsmith 2020-03-18 14:49:31 -04:00
parent 4b69914181
commit 594a0b41d7

View File

@ -83,12 +83,12 @@ function generateForCurrentRow() {
const out_doc = DocumentApp.openById(out_file.getId());
// Copy header
out_doc.getHeader().clear();
copySection(template_doc.getHeader(), out_doc.getHeader());
if (!out_doc.getHeader()) out_doc.addHeader();
copySection(template_doc.getHeader(), out_doc.getHeader().clear());
// Copy footer
out_doc.getFooter().clear();
copySection(template_doc.getFooter(), out_doc.getFooter());
if (!out_doc.getFooter()) out_doc.addFooter();
copySection(template_doc.getFooter(), out_doc.getFooter().clear());
const insert_point = template_doc
.getBody()