Paragraph And Run¶
featherdoc::Paragraph is the editing handle for a Word paragraph.
featherdoc::Run is the editing handle for text inside a paragraph with its
own run-level formatting, language, and direction metadata.
Common Tasks¶
Use this page when editing text runs or paragraph layout:
Replace a whole paragraph: call
Paragraph::set_text(...).Add styled text inside a paragraph: call
add_run(...)and then set run font, color, language, or direction metadata.Insert adjacent content: use
insert_paragraph_before(...),insert_paragraph_after(...),insert_run_before(...), orinsert_run_after(...).Preserve nearby formatting: use the
insert_*_like_*helpers before changing text.Tune layout: use paragraph alignment, bidirectional layout, and indent APIs.
Success And Failure Semantics¶
Return shape |
Success |
Failure or no-op |
|---|---|---|
|
|
|
|
Contains the requested formatting, layout, language, or direction value. |
Empty means the property is not explicitly set or cannot be resolved. |
|
Returned handles point at inserted or appended paragraph/run nodes. |
Use the returned handle for follow-up formatting. |
Iterator references |
|
Call |
Short Example¶
auto paragraph = doc.body_template().append_paragraph("Status:");
auto value = paragraph.add_run(" approved", featherdoc::formatting_flag::bold);
value.set_font_family("Aptos");
paragraph.set_alignment(featherdoc::paragraph_alignment::center);
Typed Signature Guide¶
Use this table when you need the exact argument shape before writing code.
Indexes are zero-based where an API accepts an index. Methods returning
bool report whether the underlying XML node could be changed.
Signature |
Parameters |
Return semantics |
|---|---|---|
|
|
|
|
|
New |
|
|
New paragraph handle inserted before the current paragraph. |
|
|
New paragraph handle inserted after the current paragraph. |
|
|
|
|
|
|
|
|
New run handle inserted before the current run. |
|
|
New run handle inserted after the current run. |
|
|
|
|
|
|
|
|
|
Paragraph Text And Iteration¶
Method |
Returns |
Purpose |
|---|---|---|
|
|
Advance the paragraph iterator to the next paragraph. |
|
|
Check whether the iterator can advance. |
|
|
Replace all text in the current paragraph. |
|
|
Remove the current paragraph. |
|
|
Access the run iterator for the current paragraph. |
|
|
Append a run with optional basic formatting. |
|
|
Insert a paragraph before the current paragraph. |
|
|
Insert a paragraph after the current paragraph. |
|
|
Insert a paragraph before this one and copy paragraph properties. |
|
|
Insert a paragraph after this one and copy paragraph properties. |
Paragraph Layout¶
Method |
Returns |
Purpose |
|---|---|---|
|
|
Inspect right-to-left paragraph layout metadata. |
|
|
Enable or disable right-to-left paragraph layout. |
|
|
Remove explicit right-to-left paragraph metadata. |
|
|
Read paragraph alignment. |
|
|
Set paragraph alignment. |
|
|
Remove explicit paragraph alignment. |
|
|
Read left or right indent in twips. |
|
|
Read first-line or hanging indent. |
|
|
Set the left indent in twips. |
|
|
Set the right indent in twips. |
|
|
Set the first-line indent. |
|
|
Set the hanging indent. |
Run Text And Styling¶
Method |
Returns |
Purpose |
|---|---|---|
|
|
Read the current run text. |
|
|
Replace the current run text. |
|
|
Remove the current run. |
|
|
Insert a run before the current run. |
|
|
Insert a run after the current run. |
|
|
Insert a run before this one and copy run properties. |
|
|
Insert a run after this one and copy run properties. |
|
|
Read the run style id. |
|
|
Read the primary run font family. |
|
|
Set the primary run font family. |
|
|
Read the run text color value. |
|
|
Inspect basic run styling. |
|
|
Inspect strikethrough styling. |
|
|
Inspect vertical script styling. |
|
|
Read the run font size in points. |
Run Language And Direction¶
Method |
Returns |
Purpose |
|---|---|---|
|
|
Read the primary language metadata. |
|
|
Read East Asian language metadata. |
|
|
Read bidirectional language metadata. |
|
|
Set the primary language metadata. |
|
|
Set East Asian language metadata. |
|
|
Set bidirectional language metadata. |
|
|
Inspect right-to-left run metadata. |
|
|
Enable or disable right-to-left run metadata. |
Example¶
auto paragraph = doc.body_template().append_paragraph("Title");
paragraph.set_alignment(featherdoc::paragraph_alignment::center);
auto emphasized = paragraph.add_run(
" approved",
featherdoc::formatting_flag::bold);
emphasized.set_language("en-US");
auto &run = paragraph.runs();
if (run.has_next()) {
run.next().set_font_family("Aptos");
}