IRONSOFTWAREHOME

Header Disappears After SaveAs in IronWord

Curtis Chau
Curtis Chau
Updated: August 2, 2026
Please note: This behavior has only been reported in one environment and is not corroborated by IronWord's changelog — other IronWord guides use SaveAs() as their standard save call with no reported header loss. Treat this as a possible environment-specific quirk rather than a confirmed product defect, and verify against your own environment before applying the workaround below.

In some environments, populating a DOCX template with IronWord and writing the result with SaveAs() has been observed to drop the template's header from the generated file, even though the placeholders merge correctly.

Header (e.g. "City Attorney Cover Sheet") is visible in the original DOCX
but missing in the generated file after calling SaveAs().
Text

Word template with unreplaced placeholders and no header

In the environment where this was observed, the header was preserved when writing the document with Save() rather than SaveAs(). This has not been corroborated across other environments or in IronWord's changelog - other IronWord guides use SaveAs() as their standard save call without a header-loss issue, so treat this as environment-specific rather than a confirmed product defect.

Solution

1. Load the Template

Open the source DOCX with WordDocument.

using IronWord;
using System.Collections.Generic;

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

var doc = new WordDocument(templatePath);
C#

2. Replace the Placeholders

Merge your values through doc.Texts, a straightforward find/replace approach; for placeholder-heavy templates using MERGEFIELD syntax, IronWord's dedicated WordDocument.MailMerge API is also available.

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));
}
C#

Iterating each entry over doc.Texts swaps every placeholder token for its merge value across the document body.

3. Save With Save(), Not SaveAs()

In the environment where this issue was observed, writing the output with doc.Save(outputPath) kept the header intact, while doc.SaveAs(outputPath) dropped it. Treat this as a workaround to try, not a confirmed universal behavior difference between the two methods.

doc.Save(outputPath);
C#

Merged Word document with header preserved and placeholders filled

Notes

  • If your workflow requires SaveAs(): verify on the latest IronWord version whether the header survives in your environment.
  • If the issue reappears: pin to a previously working version as a short-term mitigation while the behavior is investigated.
Please note: Placeholders are still found and replaced during traversal even when the header is lost, so a successful merge alone is not confirmation the header was kept. Open the output and check.
Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 56,401Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronWord
nuget.org/packages/IronWord/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronWord"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronWord to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronWord.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required