Exact Line Spacing for Stacked Lines in IronWord
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");
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");
Imports IronSoftware.Abstractions.Word
Dim doc As New WordDocument()
Dim addressLines As String() = {
"Max Mustermann",
"Musterstraße 42",
"12345 Musterstadt",
"Deutschland"
}
For Each line As String In addressLines
Dim para As New Paragraph(New TextContent(line))
para.LineSpacing = New LineSpacing() With {
.LineSpacingRule = LineSpacingRules.Exact
}
doc.AddParagraph(para)
Next
doc.SaveAs("address3.docx")
The foreach builds one paragraph per line, sets the exact rule, and writes the result to address3.docx.
Output

Notes and Limitations
- Avoid
ParagraphSpacing: the class is not available in IronWord2026.4.1, even though it appears in some examples. SpacingBeforeandSpacingAfterset to0do not work as expected in2026.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 = 210also 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.

