Paragraphs and text
A Paragraph is the basic building block of a document. Its text flows automatically and wraps at the page margins, so you never position text yourself.
Add a paragraph
AddParagraph appends a paragraph to a document, a section, a table cell, a list item, a float or a shape text box. The overload taking a string is a shortcut for adding a paragraph and a single text run.
doc.AddParagraph("A paragraph is the basic building block of a document. " +
"Its text flows automatically and wraps at the page margins.");doc.AddParagraph("A paragraph is the basic building block of a document. "
"Its text flows automatically and wraps at the page margins.");doc.AddParagraph("A paragraph is the basic building block of a document. " +
"Its text flows automatically and wraps at the page margins.")doc.addParagraph("A paragraph is the basic building block of a document. "
+ "Its text flows automatically and wraps at the page margins.");await doc.addParagraphWithText('A paragraph is the basic building block of a document. ' +
'Its text flows automatically and wraps at the page margins.');[doc AddParagraphWithText:@"A paragraph is the basic building block of a document. "
"Its text flows automatically and wraps at the page margins."];$doc->AddParagraph("A paragraph is the basic building block of a document. " .
"Its text flows automatically and wraps at the page margins.");doc.AddParagraph("A paragraph is the basic building block of a document. "
"Its text flows automatically and wraps at the page margins.")doc.AddParagraph("A paragraph is the basic building block of a document. " +
"Its text flows automatically and wraps at the page margins.")
Text runs and character styling
A paragraph contains a sequence of TextRun objects. Each run carries its own character style, so mixed formatting is expressed by adding several runs. AddText returns the run it created, and GetTextStyledElement exposes the style.

Setting the style on the paragraph instead of a run establishes the default for everything the paragraph contains.
Justification
SetJustificationMode accepts a left (the default), center, or right justification value.

Indents, spacing, and borders
SetTextIndent indents only the first line, while SetStartIndent and SetEndIndent indent the whole block. SetSpaceBefore and SetSpaceAfter add vertical space, and SetBorder draws a frame around the paragraph.

Tab stops
Tab stops align columns of text without the overhead of a table. Add explicit stops with AddTabStop, or set a repeating interval with SetDefaultTabStop.

Use a table instead when the columns need borders, shading, or cells that wrap onto several lines.
Hyperlinks
AddHyperlink creates a text run with a link target attached. The visual styling is up to you. Links are not colored or underlined automatically.

An existing run can be turned into a link with SetHyperlinkTarget.
Line breaks
A \n inside a text run forces a line break without starting a new paragraph, which is convenient for addresses and similar blocks.
Further Reading
Last updated
Was this helpful?