Remove Spacing Between Paragraphs in Address Blocks

When you stack short lines like an address block, IronWord's default paragraph spacing leaves a visible gap between each line. To close that gap, set an exact line-spacing rule on every paragraph so each line gets a fixed height with no extra padding. Verified on IronWord 2026.4.1.

Solution

1. Create the Document and List the Lines

Start a new WordDocument and collect the lines you want stacked together.

WordDocument doc = new WordDocument();
string[] addressLines =
{
   "Max Mustermann",
   "Musterstraße 42",
   "12345 Musterstadt",
   "Deutschland"
};
WordDocument doc = new WordDocument();
string[] addressLines =
{
   "Max Mustermann",
   "Musterstraße 42",
   "12345 Musterstadt",
   "Deutschland"
};
Dim doc As New WordDocument()
Dim addressLines As String() = {
    "Max Mustermann",
    "Musterstraße 42",
    "12345 Musterstadt",
    "Deutschland"
}
$vbLabelText   $csharpLabel

2. Apply an Exact Line-Spacing Rule to Each Paragraph

For each line, build a Paragraph and set its LineSpacing to a LineSpacing object using the Exact rule. This gives every line a fixed height and removes the inter-line gap.

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);
}
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);
}
Dim para As Paragraph
For Each line As String In addressLines
    para = New Paragraph(New TextContent(line))
    para.LineSpacing = New IronSoftware.Abstractions.Word.LineSpacing() With {
        .LineSpacingRule = IronSoftware.Abstractions.Word.LineSpacingRules.Exact
    }
    doc.AddParagraph(para)
Next
$vbLabelText   $csharpLabel

The line-spacing types live in the IronSoftware.Abstractions.Word namespace. Available types and properties vary by version, so confirm against the release you are running.

3. Save the Document

doc.SaveAs("address3.docx");
doc.SaveAs("address3.docx");
doc.SaveAs("address3.docx")
$vbLabelText   $csharpLabel

Address block with tight line spacing between paragraphs

If you prefer an explicit value over the Exact rule, para.SpacingBetweenLines = 210 also produces tight spacing.

Debug Tips

  • Do not use ParagraphSpacing: the class is not available in 2026.4.1, even though it appears in some examples.
  • Avoid zeroing SpacingBefore and SpacingAfter: in 2026.4.1, setting both to 0 makes the paragraph text invisible while the paragraph stays in the document. This behavior is under investigation; use the exact line-spacing rule instead.

WarningSetting SpacingBefore and SpacingAfter to 0 in IronWord 2026.4.1 hides the paragraph text. Use the Exact line-spacing rule shown above to control spacing reliably.

For more on placing text, 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 47,210 | Version: 2026.7 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast? PM > Install-Package IronWord
run a sample watch your data become a Word doc.