@@ -266,8 +266,20 @@ export function buildMultiSectionIdentifier(
266266 sectionMetadata : SectionMetadata [ ] ,
267267 pageStyles ?: { alternateHeaders ?: boolean } ,
268268 converterIds ?: {
269- headerIds ?: { default ?: string | null ; first ?: string | null ; even ?: string | null ; odd ?: string | null } ;
270- footerIds ?: { default ?: string | null ; first ?: string | null ; even ?: string | null ; odd ?: string | null } ;
269+ headerIds ?: {
270+ default ?: string | null ;
271+ first ?: string | null ;
272+ even ?: string | null ;
273+ odd ?: string | null ;
274+ titlePg ?: boolean ;
275+ } ;
276+ footerIds ?: {
277+ default ?: string | null ;
278+ first ?: string | null ;
279+ even ?: string | null ;
280+ odd ?: string | null ;
281+ titlePg ?: boolean ;
282+ } ;
271283 } ,
272284) : MultiSectionHeaderFooterIdentifier {
273285 const identifier = defaultMultiSectionIdentifier ( ) ;
@@ -299,12 +311,11 @@ export function buildMultiSectionIdentifier(
299311 } ) ;
300312 }
301313
302- // Track per-section titlePg from section metadata (w:titlePg element in OOXML)
303- // Note: The presence of a 'first' header/footer reference does NOT mean titlePg is enabled.
304- // The w:titlePg element must be present in sectPr to use first page headers/footers.
305- // Track per-section titlePg from section metadata (w:titlePg element in OOXML)
306- // Store explicit false so later sections don't inherit section 0's value.
307- identifier . sectionTitlePg . set ( idx , section . titlePg === true ) ;
314+ // Track per-section titlePg from section metadata (w:titlePg element in OOXML).
315+ // The presence of a 'first' header/footer reference does NOT mean titlePg is enabled.
316+ if ( Object . prototype . hasOwnProperty . call ( section , 'titlePg' ) ) {
317+ identifier . sectionTitlePg . set ( idx , section . titlePg === true ) ;
318+ }
308319 }
309320
310321 // Set legacy fields from section 0 for backward compatibility
@@ -322,7 +333,7 @@ export function buildMultiSectionIdentifier(
322333 // Only fill in null values - don't override existing refs from section metadata
323334 // Also fall back to converter's titlePg if not set from section metadata
324335 if ( converterIds ?. headerIds ) {
325- if ( ! identifier . titlePg && ( converterIds . headerIds as { titlePg ?: boolean } ) . titlePg ) {
336+ if ( ! identifier . titlePg && converterIds . headerIds . titlePg ) {
326337 identifier . titlePg = true ;
327338 }
328339 identifier . headerIds . default = identifier . headerIds . default ?? converterIds . headerIds . default ?? null ;
@@ -331,7 +342,7 @@ export function buildMultiSectionIdentifier(
331342 identifier . headerIds . odd = identifier . headerIds . odd ?? converterIds . headerIds . odd ?? null ;
332343 }
333344 if ( converterIds ?. footerIds ) {
334- if ( ! identifier . titlePg && ( converterIds . footerIds as { titlePg ?: boolean } ) . titlePg ) {
345+ if ( ! identifier . titlePg && converterIds . footerIds . titlePg ) {
335346 identifier . titlePg = true ;
336347 }
337348 identifier . footerIds . default = identifier . footerIds . default ?? converterIds . footerIds . default ?? null ;
0 commit comments