Skip to content
English
  • There are no suggestions because the search field is empty.

IronWord - Header Disappears After SaveAs When Filling a Word Template

If you are using IronWord to populate a DOCX template and the header disappears after saving, this can occur when using SaveAs(). The recommended workaround is to use Save() instead of SaveAs(), which resolved the issue in the customer’s case.

Environment

  • Product: IronWord
  • Version observed: 2026.2.1
  • App type: .NET 8 Console Application
  • OS: Windows 11 Enterprise x64 (24H2)

Symptoms

  • Placeholders are found during traversal, but output changes may not appear as expected.
  • The template’s header (e.g., “City Attorney Cover Sheet”) is visible in the original DOCX but missing in the generated file after calling SaveAs().

Solution (Workaround)

  1. Load the DOCX template using WordDocument.
  2. Apply placeholder replacements (recommended: use doc.Texts replacements for template merging).
  3. Save the output using doc.Save(outputPath) instead of doc.SaveAs(outputPath).

Example Code (C#)

using IronWord;
using System.Collections.Generic;

var templatePath = @"C:\Templates\CityAttorneyCoverSheetTemplate.docx";
var outputPath   = @"C:\Output\merged.docx";

var doc = new WordDocument(templatePath);

// Replace placeholders (recommended template approach)
var replacements = new Dictionary<string, string>
{
    ["{CaseNumber}"] = "2026-CR-12345",
    ["{DefendantName}"] = "John Doe",
    ["{DefendantAge}"] = "34",
    ["{DefendantAttorney}"] = "Jane Smith",
};

foreach (var kv in replacements)
{
    doc.Texts.ForEach(t => t.Replace(kv.Key, kv.Value));
}

// Workaround: Save() preserves the header where SaveAs() may not
doc.Save(outputPath);

Before

After

Notes

  • If your workflow requires SaveAs(), confirm whether the header is preserved on the latest IronWord version in your environment.
  • If the issue reappears, a short-term mitigation is to pin to a previously working version while the behavior is investigated.