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

IronWord How to Remove Spacing Between Paragraphs for Multi-Line Address Blocks

Overview

When you stack short lines like an address block in IronWord, the default paragraph spacing leaves a gap between each line. This article shows you how to remove that gap by setting an exact line-spacing rule on each paragraph. The approach is verified on IronWord 2026.4.1.

Prerequisites
  • IronWord 2026.4.1
  • A .NET project
Steps
  1. Create the document and list the lines you want to stack together.
  2. 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 each paragraph to the document and save.

Complete working example:

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");

Result:

Notes and Limitations

  • Do not use the ParagraphSpacing class. It is not available in IronWord 2026.4.1, even though it appears in some examples.
  • In 2026.4.1, setting SpacingBefore and SpacingAfter to 0 does not work as expected. 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 to set an explicit value.
  • Available types and properties vary by version. The line-spacing types here live in the IronSoftware.Abstractions.Word namespace.
References