Headers
Headers are full editable document stories attached to each DocumentSection in paginated mode. They support rich text, alignment, tables, images, and live inline fields such as document title or page numbers.
- Included in: All configurations in
DocumentEditorLayoutMode.paginated - Model:
PageHeaderFooteronSectionFormat(header,firstPageHeader,evenPageHeader) - Pure-Dart import:
package:vyuh_document/types.dart
Quick example
dart
final format = SectionFormat(
differentFirstPage: true,
margins: const PageMargins(
top: 72,
bottom: 72,
left: 72,
right: 72,
header: 36,
footer: 36,
),
header: PageHeaderFooter(
blocks: [
ParagraphBlock(
id: BlockId('hdr-default'),
children: [TextRun(text: 'Employee Handbook — Confidential')],
),
],
),
firstPageHeader: const PageHeaderFooter(blocks: []), // Clean cover page
);
controller.setSectionFormat(0, format);What you can configure
Header variants on SectionFormat
| Property | Type | Purpose |
|---|---|---|
header | PageHeaderFooter? | Default (odd / all-page) running header for the section |
firstPageHeader | PageHeaderFooter? | Dedicated header for page 1 of the section when differentFirstPage: true |
evenPageHeader | PageHeaderFooter? | Alternating header for even-numbered pages in mirrored/book layouts |
differentFirstPage | bool | Activates firstPageHeader (leave its blocks empty to suppress the header on a cover page) |
margins.header | double (points) | Distance from the top physical page edge to the header region |
PageHeaderFooter properties
| Property | Type | Purpose |
|---|---|---|
blocks | List<DocumentBlock> | Full story blocks rendered inside the header (paragraphs, aligned tables, logos, inline fields) |
height | double? | Optional explicit minimum height; otherwise grows dynamically with content while respecting page margins |
bodyPolicy | PageRegionBodyPolicy | Controls how header growth interacts with the main body region |
Interactive & programmatic editing
- Double-click in editor: Double-clicking the top margin area of any page activates header editing directly in place while dimming the main body.
- Focus programmatically:
dart
controller.focusPageRegion(
sectionIndex: 0,
region: PageRegionKind.header,
);- Insert live fields inside a header: Once focused in the header region, call
insertStandardInlineField(StandardInlineFields.documentTitle)orStandardInlineFields.pageNumber(see Inline fields). - Return to main body: Double-click the page body or press
Escape.
Restricting usage
- Disable headers completely: Mount the editor in
DocumentEditorLayoutMode.pageless— running headers and footers do not appear in pageless mode. - Lock header text while allowing body edits: Use
DocumentPolicy/ region protection so readers see branded headers without being able to edit them.
Format parity
| DOCX | HTML | Markdown | |
|---|---|---|---|
Native word/header*.xml (default, first, even) with full round-trip | Painted on every physical page with resolved fields | Emitted as semantic document header metadata | Body-focused export (running headers omitted) |