IRONSOFTWAREHOME

Exact Line Spacing for Stacked Lines in IronWord

Curtis Chau
Curtis Chau
Updated: August 21, 2026

Stacking short lines like an address block leaves a gap between each line, because the default paragraph spacing applies between them. Remove that gap by setting an exact line-spacing rule on each paragraph. Verified on IronWord 2026.4.1.

Solution

1. List the Lines to Stack

Create the document and gather the lines you want stacked together.

2. Apply the Exact Line-Spacing Rule

For each line, create a Paragraph and set its LineSpacing to a LineSpacing object that uses the Exact rule. This gives each line a fixed height with no extra gap.

3. Add the Paragraphs and Save

Add each paragraph to the document, then save.

WordDocument doc = new WordDocument();
string[] addressLines =
{
   "Max Mustermann",
   "Musterstraße 42",
   "12345 Musterstadt",
   "Deutschland"
};
foreach (string line in addressLines)
{
    Paragraph para = new Paragraph(new TextContent(line));
    para.LineSpacing = new IronSoftware.Abstractions.Word.LineSpacing()
    {
        LineSpacingRule = IronSoftware.Abstractions.Word.LineSpacingRules.Exact,
    };    doc.AddParagraph(para); }  doc.SaveAs("address3.docx");
C#

The foreach builds one paragraph per line, sets the exact rule, and writes the result to address3.docx.

Output

Address block with tight line spacing and no extra gaps between lines

Notes and Limitations

  • Avoid ParagraphSpacing: the class is not available in IronWord 2026.4.1, even though it appears in some examples.
  • SpacingBefore and SpacingAfter set to 0 do not work as expected in 2026.4.1: the paragraph text becomes invisible while the paragraph stays in the document. This behavior is under investigation. Use the exact line-spacing rule shown above instead.
  • Alternative: para.SpacingBetweenLines = 210 also produces tight spacing if you prefer an explicit value.
  • Namespace: available types and properties vary by version. The line-spacing types here live in IronSoftware.Abstractions.Word.

For more on writing text into a document, see the Add Text how-to.

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