Struct genpdf::elements::Paragraph[][src]

pub struct Paragraph { /* fields omitted */ }
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.

Note that the line height and spacing is currently calculated based on the style of the entire paragraph. If the font family or font size is changed in the Style settings for a string, the line height and spacing might be incorrect.

Examples

With setters:

use 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(genpdf::Alignment::Center);

Chained:

use genpdf::{elements, style};
let p = elements::Paragraph::default()
    .string("This is an ")
    .styled_string("important", style::Color::Rgb(255, 0, 0))
    .string(" message!")
    .aligned(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.

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

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.