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.
Trait Implementations
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.
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
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
impl RefUnwindSafe for Paragraph
impl UnwindSafe for Paragraph
Blanket Implementations
Mutably borrows from an owned value. Read more