Struct genpdf::elements::TableLayout [−][src]
pub struct TableLayout { /* fields omitted */ }
Expand description
Arranges elements in columns and rows.
This struct can be used to layout arbitrary elements in columns in rows, or to draw typical
tables. You can customize the cell style by providing a CellDecorator
implementation.
If you want to print a typical table with borders around the cells, use the
FrameCellDecorator
.
The column widths are determined by the weights that have been set in the constructor. The table always uses the full width of the provided area.
Examples
With setters:
use genpdf::elements; let mut table = elements::TableLayout::new(vec![1, 1]); table.set_cell_decorator(elements::FrameCellDecorator::new(true, true, false)); let mut row = table.row(); row.push_element(elements::Paragraph::new("Cell 1")); row.push_element(elements::Paragraph::new("Cell 2")); row.push().expect("Invalid table row");
Chained:
use genpdf::elements; let table = elements::TableLayout::new(vec![1, 1]) .row() .element(elements::Paragraph::new("Cell 1")) .element(elements::Paragraph::new("Cell 2")) .push() .expect("Invalid table row");
Implementations
Creates a new table layout with the given column weights.
The column weights are used to determine the relative width of the columns. The number of column weights determines the number of columns in the table.
Sets the cell decorator for this table.
Adds a row to this table using the TableLayoutRow
helper struct.
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.
Auto Trait Implementations
impl !RefUnwindSafe for TableLayout
impl !Send for TableLayout
impl !Sync for TableLayout
impl Unpin for TableLayout
impl !UnwindSafe for TableLayout