pub struct Table { /* private fields */ }Expand description
Represents a simple table in a PDF document
Implementations§
Source§impl Table
impl Table
Sourcepub fn with_equal_columns(num_columns: usize, total_width: f64) -> Self
pub fn with_equal_columns(num_columns: usize, total_width: f64) -> Self
Create a table with equal column widths
Sourcepub fn set_position(&mut self, x: f64, y: f64) -> &mut Self
pub fn set_position(&mut self, x: f64, y: f64) -> &mut Self
Set table position
Sourcepub fn set_options(&mut self, options: TableOptions) -> &mut Self
pub fn set_options(&mut self, options: TableOptions) -> &mut Self
Set table options
Sourcepub fn options(&self) -> &TableOptions
pub fn options(&self) -> &TableOptions
Get a reference to the table’s current options.
Sourcepub fn add_header_row(
&mut self,
cells: Vec<String>,
) -> Result<&mut Self, PdfError>
pub fn add_header_row( &mut self, cells: Vec<String>, ) -> Result<&mut Self, PdfError>
Add a header row
Sourcepub fn set_last_row_height(&mut self, height: f64) -> &mut Self
pub fn set_last_row_height(&mut self, height: f64) -> &mut Self
Set the height of the last added row
Sourcepub fn add_row_with_alignment(
&mut self,
cells: Vec<String>,
align: TextAlign,
) -> Result<&mut Self, PdfError>
pub fn add_row_with_alignment( &mut self, cells: Vec<String>, align: TextAlign, ) -> Result<&mut Self, PdfError>
Add a data row with specific alignment
Sourcepub fn add_custom_row(
&mut self,
cells: Vec<TableCell>,
) -> Result<&mut Self, PdfError>
pub fn add_custom_row( &mut self, cells: Vec<TableCell>, ) -> Result<&mut Self, PdfError>
Add a row with custom cells (allows colspan)
Sourcepub fn get_height(&self) -> f64
pub fn get_height(&self) -> f64
Get total table height
Sourcepub fn header_count(&self) -> usize
pub fn header_count(&self) -> usize
Number of leading header rows in this table.
Sourcepub fn render(&self, graphics: &mut GraphicsContext) -> Result<(), PdfError>
pub fn render(&self, graphics: &mut GraphicsContext) -> Result<(), PdfError>
Render the table to a graphics context.
Back-compat note: this method is vertical-overflow-unaware by design.
Rows past the page boundary are still drawn off-page (silent overflow).
Callers concerned with overflow should use Table::render_with_split
or Table::render_strict, or crate::page_tables::DocumentTables::add_paginated_table.
Sourcepub fn render_with_split(
&self,
graphics: &mut GraphicsContext,
bottom_y: f64,
) -> Result<Option<Table>, PdfError>
pub fn render_with_split( &self, graphics: &mut GraphicsContext, bottom_y: f64, ) -> Result<Option<Table>, PdfError>
Render as many leading rows as fully fit above bottom_y; return the
unrendered tail as a fresh Table (with the same column_widths and
options), or None when everything fit.
Tail position is a sentinel (start_x, 0.0) — the caller MUST call
Table::set_position on the returned tail before using it for
rendering or fit checks. Calling render_with_split on a tail without
repositioning will report 0 rows fitting (since start_y - row_height < bottom_y
for any positive bottom_y) and yield a tail identical to the input.
For batteries-included pagination, see
crate::page_tables::DocumentTables::add_paginated_table.
§Errors
Returns PdfError::InvalidStructure when bottom_y is not a finite
value (NaN or ±∞).
Sourcepub fn render_strict(
&self,
graphics: &mut GraphicsContext,
bottom_y: f64,
) -> Result<(), PdfError>
pub fn render_strict( &self, graphics: &mut GraphicsContext, bottom_y: f64, ) -> Result<(), PdfError>
Strict variant: pre-flight check the table against bottom_y. If any
row would overflow, return PdfError::TableOverflow without
drawing anything; otherwise render normally.
§Errors
Returns PdfError::InvalidStructure when bottom_y is not finite.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnsafeUnpin for Table
impl UnwindSafe for Table
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more