lopdf-table
A composable table drawing library for PDFs built on lopdf.
Features
- Ergonomic API: Simple builder pattern for creating tables
- Automatic Sizing: Calculates column widths and row heights based on content
- Flexible Styling: Customize colors, borders, padding, and alignment
- Cell Spanning: Support for colspan and rowspan
- Trait-based Design: Extends lopdf's Document type seamlessly
Installation
Add to your Cargo.toml:
[]
= "0.1"
Usage
Basic Table
use Document;
use ;
// Create a document
let mut doc = new;
// Create a table
let table = new
.add_row
.add_row
.add_row
.with_border;
// Draw the table on a page
doc.draw_table?;
Styled Table
use ;
// Create header style
let header_style = RowStyle ;
let header_cell_style = CellStyle ;
// Apply styles
let table = new
.add_row;
Custom Column Widths
let table = new
.add_row
.with_column_widths;
Examples
See the examples/ directory for complete working examples:
basic_table.rs- Simple table with headers and datastyled_table.rs- Advanced styling with colors and formatting
Run examples with:
License
MIT