fix: titlePg only on the section group that begins its header set

A continuous section pushed onto a fresh page by a page break repeated
titlePg, and Word blanks a titlePg section's first page — the running
header, footer and watermark vanished from that page.
This commit is contained in:
Steffen Becker committed 2026-08-30 10:06:42 +00:00
1 parent 1660e07873
commit 9d6f0bebb9
1 file changed
+5 -3
+5 -3
View File
@@ -2664,9 +2664,11 @@ export async function buildDocx(
} }
: {}),
// Word blanks a titlePg section's first page when no w:type="first" header is
// referenced, and every section restarts that logic — so a section merely
// reusing the last set through the clamp must not repeat titlePg.
...(setAt(g.section).differentFirstPage && g.section < hfSets.length ? { titlePage: true } : {}),
// referenced, and every section restarts that logic — even a continuous one
// that a page break pushes onto a fresh page. So only the group that begins
// its header set carries titlePg; later groups of the set must not repeat it.
...(setAt(g.section).differentFirstPage && g.section < hfSets.length
&& groups.findIndex((x) => x.section === g.section) === i ? { titlePage: true } : {}),
...(i > 0 && !(setAt(g.section).pageNumberStart != null && groups.findIndex((x) => x.section === g.section) === i)
? { type: SectionType.CONTINUOUS } : {}),
...(g.columns