ParagraphFormatting LineSpacingRule property default value

Hello,

I have noticed that when you create new empty document in Word, the default value for Line Spacing Rule is ‘Multiply’, however, when you create an empty word document in aspose, Line Spacing Rule is set to ‘Single’. Also when you set a LineSpacing to some value, without changing Line Spacing Rule, it gets changed to ‘Multiply’ on it’s own.

I couldn’t find any information about the implemented behavior of Line Spacing Rule in the documentation - could you please help me with this?

Thanks
Aga

@acturisaspose,

Thanks for your inquiry. Please read the detail of LineSpacingRule enumeration and ParagraphFormat.LineSpacing property

The line spacing is specified in the LineSpacing property as the number of lines. One line equals 12 points. You need to set the line spacing and line rule according to your requirement.

Hi Tahir,

sorry, there is really not to much information in the links you have provided (I have already been there before asking on the forum).
What i need to know is:

  • what is the default value Line Spacing Rule is set up to in ParagraphFormatting
  • why, in the situation described above, Line Spacing Rule changes itself on it’s own

@acturisaspose,

Thanks for your inquiry. The default value of ParagraphFormat.LineSpacing is 12 and ParagraphFormat.LineSpacingRule has “Multiple”. When the line spacing is 12, Aspose.Words sets line spacing rule to single because one line equals to 12 points.

Following code example shows how to use these properties. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Specify linespacing 1.5 line
builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
// The line spacing is specified in the LineSpacing property as the number of lines.
// One line equals 12 points. so 1.5 lines = 18 points

builder.ParagraphFormat.LineSpacing = 18;
// Insert some text
builder.Writeln("This is paragraph with '1.5 line' spacing rule");
// The same technique you can use to specify Document spacing rule
builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
builder.ParagraphFormat.LineSpacing = 24;

builder.Writeln("This is paragraph with 'Double' spacing rule");
builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;

builder.ParagraphFormat.LineSpacing = 36;
builder.Writeln("This is paragraph with 'Multiple' spacing rule");
builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.AtLeast;
builder.ParagraphFormat.LineSpacing = 12;
builder.Writeln("This is paragraph with 'AtLeast' spacing rule");

builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly;
builder.ParagraphFormat.LineSpacing = 10;

builder.Writeln("This is paragraph with 'Exactly' spacing rule");

doc.Save(MyDir + "Out.docx");

yes, thank you, this is exactly what i needed!

@acturisaspose,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.