Paragraph Style
ParagraphStyle controls indentation, spacing, borders, tab stops, alignment, pagination, and CJK-specific behaviours.
Indented Quote Block
Use case: Create a visually distinct quotation style.
C#
1var quote = new ParagraphStyle
2{
3 Indent = new ParagraphIndentation
4 {
5 Left = new DocumentUnit(0.5, Units.inch),
6 Right = new DocumentUnit(0.5, Units.inch),
7 },
8SpacingBetweenLines = new Spacing { Before = 6, After = 6, Line = 1.2 },
9ParagraphBorders = new ParagraphBorders
10{
11 Left = new BorderStyle { BorderColor = Color.Gray, BorderSize = 3.0, BorderValue = BorderValues.single },
12},
13};
14
15var p = doc.AddParagraph();
16p.AddText("“The only way to do great work is to love what you do.” — Steve Jobs");
17p.Style = quote;
Hanging Indent for Bibliography
Use case: Format a bibliography entry with a hanging indent.
C#
1var bib = new ParagraphStyle
2{
3 Indent = new ParagraphIndentation
4 {
5 Left = new DocumentUnit(0.5, Units.inch),
6 Hanging = new DocumentUnit(0.5, Units.inch),
7 }
8};
9
10var p = doc.AddParagraph();
11p.AddText("Doe, J. (2024). Title of the article. Journal of Examples, 12(3), 45-67.");
12p.Style = bib;
Justified Paragraph
Use case: Produce a fully justified body paragraph.
C#
1var justified = new ParagraphStyle
2{
3 Justification = JustificationValues.Both,
4 SpacingBetweenLines = new Spacing { After = 8, Line = 1.15 }
5};
6
7var p = doc.AddParagraph();
8p.AddText("Long body text that should be justified across the page width...");
9p.Style = justified;
Related API
Frequently asked questions
How do I add a border around a paragraph?
Set ParagraphBorders on the ParagraphStyle, with a BorderStyle for each edge.
How do I keep a paragraph together with the next one?
Set keepWithNextParagraph = true on the ParagraphStyle.