Add Header
Adds a header to a Word document with customizable formatting.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing the node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- In File Descriptor - Unique identifier of the document to add header to. This comes from the Create Word or Open Word node. Default variable is
{{$message.word_fd}}. - Text - Header text content. This text will appear at the top of the specified pages.
Options
- Header Type - Determines which pages display the header:
- All Pages - Header appears on every page (default)
- First Page - Header appears only on the first page
- Font Size - Font size for the header text in points. Default is 12.
- Font Name - Font family name for the header text. Default is "Arial".
- Bold - Whether to make the header text bold. Default is true.
How It Works
The Add Header node adds formatted text to the header section of the document. When executed, the node:
- Validates the file descriptor and header text
- Retrieves the document from memory
- Iterates through all sections in the document
- Configures header settings based on the selected Header Type
- Clears any existing header content in the target section
- Adds new header text with center alignment
- Applies the specified font, size, and bold formatting
Requirements
- Valid file descriptor from Create Word or Open Word node
- Non-empty header text
- Valid font size (positive number)
- Valid font name
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid file descriptor
- Document not found
- Empty header text
- Invalid font size or font name
- Runtime errors during header creation
Usage Examples
Example 1: Company Header on All Pages
Scenario: Add a company name header to all pages of a report
// Set company name
$local.companyName = "Acme Corporation - Confidential";
Configuration:
- In File Descriptor:
{{$message.word_fd}} - Text:
{{$local.companyName}} - Header Type:
All Pages - Font Size:
10 - Font Name:
Arial - Bold:
true
Result: "Acme Corporation - Confidential" appears centered and bold at the top of every page.
Example 2: Title Page Header
Scenario: Add a special header only to the first page
// Set title page header
$local.titleHeader = "Annual Report 2025";
Configuration:
- In File Descriptor:
{{$message.word_fd}} - Text:
{{$local.titleHeader}} - Header Type:
First Page - Font Size:
14 - Font Name:
Times New Roman - Bold:
true
Result: "Annual Report 2025" appears only on the first page, allowing different or no header on subsequent pages.
Example 3: Document Reference Header
Scenario: Add a document reference number with subtle styling
// Set document reference
$local.docRef = "DOC-2025-001 | Version 1.0";
Configuration:
- In File Descriptor:
{{$message.word_fd}} - Text:
{{$local.docRef}} - Header Type:
All Pages - Font Size:
8 - Font Name:
Calibri - Bold:
false
Result: Small, non-bold reference number appears at the top of all pages.
Usage Notes
- Headers are centered by default
- The node replaces any existing header content in the target sections
- Headers apply to all sections in the document
- First Page header type enables different headers for first vs. other pages
- Headers do not affect the document's main content area
- Multiple calls to Add Header will replace previous headers
Tips for Effective Use
- Professional Sizing: Use smaller font sizes (8-10pt) for headers to avoid overwhelming the page
- Consistent Branding: Include company name or logo text in headers
- Document Tracking: Add document numbers, versions, or dates in headers
- Confidentiality: Use headers to mark confidential or draft documents
- First Page Distinction: Use "First Page" type for title pages that need different headers
- Font Pairing: Match header font with document body font for consistency
- Bold for Emphasis: Use bold for important header information
Best Practices
- Keep It Concise: Headers should be brief - one or two lines maximum
- Test Visibility: Ensure header doesn't interfere with page margins
- Standard Fonts: Use common fonts (Arial, Calibri, Times New Roman) for compatibility
- Consistent Styling: Use the same header style throughout a document set
- Consider Footers: For page numbers or additional info, use footer functionality (if available)
- Date Stamps: Include current date in headers for version tracking
Header Type Scenarios
| Header Type | Use Case | Example |
|---|---|---|
| All Pages | Standard documents, reports, letters | Company name on all pages |
| First Page | Title pages, covers, executive summaries | Report title on first page only |
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| "File descriptor cannot be empty" | No file descriptor provided | Ensure Create Word or Open Word node runs first |
| "Header text cannot be empty" | No text content provided | Provide text in the Text input |
| "Document not found" | Invalid file descriptor | Verify file descriptor matches the one from Create/Open Word |
| "Failed to add header to document" | Runtime error | Check all parameters are valid |
Font Size Guidelines for Headers
| Size (pt) | Visual Effect | Best Use |
|---|---|---|
| 8 | Very small | Document references, metadata |
| 9 | Small | Confidential markings, subtle branding |
| 10 | Standard | Company names, general headers |
| 11 | Medium | Emphasized headers |
| 12 | Large | Prominent headers, titles |
| 14+ | Very large | Cover page headers only |
Formatting Examples
Corporate Header
Text: "ACME CORPORATION | INTERNAL USE ONLY"
Font: Arial
Size: 9
Bold: true
Type: All Pages
Legal Document Header
Text: "Contract Agreement - CONFIDENTIAL"
Font: Times New Roman
Size: 10
Bold: true
Type: All Pages
Report Title Header
Text: "Quarterly Financial Report Q4 2025"
Font: Calibri
Size: 12
Bold: true
Type: First Page
Simple Reference Header
Text: "Doc ID: 2025-RPT-001"
Font: Arial
Size: 8
Bold: false
Type: All Pages
Design Considerations
- Margin Space: Headers appear in the top margin - ensure margins are adequate
- Page Layout: Headers work with all page orientations (portrait/landscape)
- Multi-Section Documents: Headers can differ between sections in complex documents
- Printing: Headers appear on printed pages - test print preview
- PDF Export: Headers are preserved when saving as PDF
- Readability: Ensure header text contrasts well with page background
Advanced Usage Patterns
Dynamic Headers with Variables
// Create dynamic header with date and user
$local.currentDate = new Date().toLocaleDateString();
$local.userName = $env.username;
$local.headerText = `Generated by ${$local.userName} on ${$local.currentDate}`;
Conditional Headers
// Different headers based on document type
if ($local.documentType === "confidential") {
$local.headerText = "CONFIDENTIAL - DO NOT DISTRIBUTE";
} else {
$local.headerText = "Internal Document";
}