pub struct Paragraph { /* private fields */ }
Expand description

A multi-line wrapped paragraph of formatted text.

If the text of this paragraph is longer than the page width, the paragraph is wrapped at word borders (and additionally at string borders if it contains multiple strings). If a word in the paragraph is longer than the page width, the text is truncated.

Use the push, string, push_styled and string_styled methods to add strings to this paragraph. Besides the styling of the text (see Style), you can also set an Alignment for the paragraph.

The line height and spacing are calculated based on the style of each string.

Examples

With setters:

use rckive_genpdf::{elements, style};
let mut p = elements::Paragraph::default();
p.push("This is an ");
p.push_styled("important", style::Color::Rgb(255, 0, 0));
p.push(" message!");
p.set_alignment(rckive_genpdf::Alignment::Center);

Chained:

use rckive_genpdf::{elements, style};
let p = elements::Paragraph::default()
    .string("This is an ")
    .styled_string("important", style::Color::Rgb(255, 0, 0))
    .string(" message!")
    .aligned(rckive_genpdf::Alignment::Center);

Implementations§

Creates a new paragraph with the given content.

Sets the alignment of this paragraph.

Sets the alignment of this paragraph and returns the paragraph.

Adds a string to the end of this paragraph.

Adds a string to the end of this paragraph and returns the paragraph.

Adds a string with the given style to the end of this paragraph.

Adds a string with the given style to the end of this paragraph and returns the paragraph.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Renders this element to the given area using the given style and font cache. Read more
Draws a frame around this element using the given line style.
Adds a padding to this element.
Sets the default style for this element and its children.
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Converts to this type from the input type.
Creates a value from an iterator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Creates a boxed element from this element.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.