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

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 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 61,140Version:2026.11just released