### Run Basic Table Example Source: https://github.com/fourbs-group/lopdf-table/blob/main/README.md Command to execute the basic table example from the `examples/` directory using Cargo. ```bash cargo run --example basic_table ``` -------------------------------- ### Run Styled Table Example Source: https://github.com/fourbs-group/lopdf-table/blob/main/README.md Command to execute the styled table example from the `examples/` directory using Cargo. ```bash cargo run --example styled_table ``` -------------------------------- ### Draw Table with Pagination in Rust Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Use `draw_table_with_pagination` to render tables that span multiple pages, repeating header rows on each new page. Configure page margins and height via `TableStyle`. Requires a `Document` instance, a starting page ID, and table dimensions. ```rust use lopdf_table::{ Table, Row, Cell, ColumnWidth, TableDrawing, TableStyle, Color, Alignment, CellStyle, RowStyle, PagedTableResult, }; let mut style = TableStyle::default(); style.page_height = Some(842.0); // A4 style.top_margin = 50.0; style.bottom_margin = 50.0; style.repeat_headers = true; let header_cell_style = CellStyle { text_color: Color::white(), bold: true, alignment: Alignment::Center, ..Default::default() }; let mut table = Table::new() .with_style(style) .with_header_rows(2) .with_column_widths(vec![ ColumnWidth::Pixels(60.0), ColumnWidth::Pixels(150.0), ColumnWidth::Auto, ColumnWidth::Pixels(80.0), ]) .with_total_width(500.0) // Title row spanning all 4 columns .add_row( Row::new(vec![Cell::new("Employee Report").bold().with_colspan(4)]) .with_style(RowStyle { background_color: Some(Color::rgb(0.15, 0.25, 0.45)), ..Default::default() }), ) // Column header row .add_row( Row::new(vec![ Cell::new("ID").with_style(header_cell_style.clone()), Cell::new("Name").with_style(header_cell_style.clone()), Cell::new("Department").with_style(header_cell_style.clone()), Cell::new("Salary").with_style(header_cell_style.clone()), ]) .with_style(RowStyle { background_color: Some(Color::rgb(0.2, 0.3, 0.5)), ..Default::default() }), ); for i in 1..=50 { table = table.add_row(Row::new(vec![ Cell::new(format!("E{i:03}")), Cell::new(format!("Employee {i}")), Cell::new("Engineering"), Cell::new(format!("${}", 50000 + i * 1000)) .with_style(CellStyle { alignment: Alignment::Right, ..Default::default() }), ])); } let result: PagedTableResult = doc.draw_table_with_pagination(first_page_id, table, (50.0, 750.0)) .expect("paginated draw failed"); println!("Rendered {} pages, final pos: {:?}", result.total_pages, result.final_position); doc.save("report.pdf").unwrap(); ``` -------------------------------- ### TableDrawing::draw_table - Render a table at a fixed position Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Renders the complete table starting at a specified (x, y) coordinate on a given PDF page. This method does not handle pagination and the table will be clipped to the available space on the page. ```APIDOC ## `TableDrawing::draw_table` — Render a table at a fixed position Draws the complete table starting at `(x, y)` on the given page. Does not paginate — the table is clipped to available space. ```rust use lopdf::{Document, Object, dictionary}; use lopdf_table::{Table, Row, Cell, TableDrawing}; let mut doc = Document::with_version("1.5"); // … set up pages_id, page_id, font resources, catalog (see full example below) … let table = Table::new() .with_border(1.0) .add_row(Row::new(vec![Cell::new("Name").bold(), Cell::new("Score").bold()])) .add_row(Row::new(vec![Cell::new("Alice"), Cell::new("98")])) .add_row(Row::new(vec![Cell::new("Bob"), Cell::new("87")])); // Draw at PDF point (50, 750) — origin is bottom-left in PDF coordinate space doc.draw_table(page_id, table, (50.0, 750.0)) .expect("table draw failed"); doc.save("output.pdf").unwrap(); ``` ``` -------------------------------- ### Create and Configure a Table with Table::new Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Use Table::new to create a table builder. Configure column widths, total width, borders, header rows, and add rows with cells. ```rust use lopdf_table::{Table, Row, Cell, ColumnWidth}; let table = Table::new() .with_total_width(500.0) .with_column_widths(vec![ ColumnWidth::Percentage(40.0), // Product: 40 % of 500 pt ColumnWidth::Auto, // Quantity: sized to content ColumnWidth::Pixels(80.0), // Price: fixed 80 pt ColumnWidth::Pixels(80.0), // Total: fixed 80 pt ]) .with_border(1.0) .with_header_rows(1) // first row repeats on every page .add_row(Row::new(vec![ Cell::new("Product").bold(), Cell::new("Qty").bold(), Cell::new("Price").bold(), Cell::new("Total").bold(), ])) .add_row(Row::new(vec![ Cell::new("Widget A"), Cell::new("5"), Cell::new("$10.00"), Cell::new("$50.00"), ])); ``` -------------------------------- ### Create and Draw a Basic Table Source: https://github.com/fourbs-group/lopdf-table/blob/main/README.md Demonstrates how to create a simple table with headers and data, and then draw it onto a PDF page using the lopdf-table library. Ensure you have a valid `page_id` and `doc` object from lopdf. ```rust use lopdf::Document; use lopdf_table::{Table, Row, Cell, TableDrawing}; // Create a document let mut doc = Document::new(); // Create a table let table = Table::new() .add_row(Row::new(vec![ Cell::new("Name").bold(), Cell::new("Age").bold(), Cell::new("City").bold(), ])) .add_row(Row::new(vec![ Cell::new("Alice"), Cell::new("30"), Cell::new("New York"), ])) .add_row(Row::new(vec![ Cell::new("Bob"), Cell::new("25"), Cell::new("London"), ])) .with_border(1.0); // Draw the table on a page doc.draw_table(page_id, table, (50.0, 750.0))?; ``` -------------------------------- ### Build Table Cells with Cell::new and Cell::from_image Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Create cells using Cell::new for text or Cell::from_image for images. Cells can be styled, merged, or contain multiple images. ```rust use lopdf_table::{Cell, CellImage, CellStyle, Alignment, BorderStyle, Color}; // Text cell with rich formatting let header = Cell::new("Revenue") .bold() .italic() .with_font_size(12.0) .with_style(CellStyle { alignment: Alignment::Right, text_color: Color::white(), background_color: Some(Color::rgb(0.2, 0.3, 0.5)), border_bottom: Some((BorderStyle::Solid, 2.0, Color::rgb(0.1, 0.1, 0.7))), ..Default::default() }); // Spanning cell (colspan=3 fills three columns) let merged = Cell::new("Q1 Summary").bold().with_colspan(3); // Image cell from raw JPEG bytes let jpeg_bytes: Vec = std::fs::read("photo.jpg").unwrap(); let img = CellImage::new(jpeg_bytes) .expect("valid JPEG") .with_max_height(120.0) .with_overlay(lopdf_table::table::ImageOverlay::new("Taken 01/01/2026")); let img_cell = Cell::from_image(img); // Multiple side-by-side images let img1 = CellImage::new(std::fs::read("a.jpg").unwrap()).unwrap(); let img2 = CellImage::new(std::fs::read("b.png").unwrap()).unwrap(); let multi_img = Cell::from_images(vec![img1, img2]); ``` -------------------------------- ### Create a Styled Table Source: https://github.com/fourbs-group/lopdf-table/blob/main/README.md Shows how to apply custom styles to table rows and cells, including background colors, text colors, alignment, and bold text. This requires importing `Color`, `CellStyle`, `RowStyle`, and `Alignment` from `lopdf_table`. ```rust use lopdf_table::{Color, CellStyle, RowStyle, Alignment}; // Create header style let header_style = RowStyle { background_color: Some(Color::rgb(0.2, 0.3, 0.5)), ..Default::default() }; let header_cell_style = CellStyle { text_color: Color::white(), bold: true, alignment: Alignment::Center, ..Default::default() }; // Apply styles let table = Table::new() .add_row( Row::new(vec![ Cell::new("Product").with_style(header_cell_style.clone()), Cell::new("Price").with_style(header_cell_style.clone()), ]) .with_style(header_style), ); ``` -------------------------------- ### Draw Table with Unicode Text using TtfFontMetrics Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Demonstrates how to use TtfFontMetrics for accurate measurement and glyph-ID encoding of Unicode text in tables. Ensure the font data is embedded into the PDF separately with a matching resource name. ```rust use lopdf_table::{TtfFontMetrics, Table, Row, Cell, TableDrawing, TableStyle}; // Load font data (caller embeds the font into the PDF separately) let font_data = std::fs::read("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf") .expect("font file not found"); let metrics = TtfFontMetrics::new(font_data.clone()) .expect("failed to parse font"); let mut style = TableStyle::default(); style.embedded_font_resource_name = Some("EF0".to_string()); // matches PDF resource name let table = Table::new() .with_style(style) .with_font_metrics(metrics) // enables glyph-ID encoding + accurate column sizing .add_row(Row::new(vec![ Cell::new("Language").bold(), Cell::new("Text").bold(), ])) .add_row(Row::new(vec![ Cell::new("German"), Cell::new("Grüße aus Berlin"), // ü, ß — accented Latin ])) .add_row(Row::new(vec![ Cell::new("Symbols"), Cell::new("© 2025 — All rights reserved ™"), ])) .with_border(1.0) .with_total_width(400.0); // The caller must embed `font_data` as a Type0/CIDFontType2 font with resource name "EF0" doc.draw_table(page_id, table, (50.0, 750.0)).expect("unicode draw failed"); doc.save("unicode_table.pdf").unwrap(); ``` -------------------------------- ### Add lopdf-table Dependency Source: https://github.com/fourbs-group/lopdf-table/blob/main/README.md Add the lopdf-table crate to your Cargo.toml file to include it in your project. ```toml [dependencies] lopdf-table = "0.1" ``` -------------------------------- ### Configure Global Table Styles with TableStyle Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Set global properties like borders, fonts, padding, and page margins for an entire table. Supports embedding TrueType fonts for Unicode rendering. ```rust use lopdf_table::{TableStyle, Color, BorderStyle, style::Padding}; let mut style = TableStyle::default(); style.border_width = 2.0; style.border_color = Color::rgb(0.2, 0.3, 0.5); style.default_font_size = 11.0; style.font_name = "Times-Roman".to_string(); style.padding = Padding::symmetric(6.0, 8.0); style.page_height = Some(842.0); // A4 style.top_margin = 50.0; style.bottom_margin = 50.0; style.repeat_headers = true; // Embedded TrueType font resource (for Unicode rendering) style.embedded_font_resource_name = Some("EF0".to_string()); style.embedded_font_resource_name_bold = Some("EF0B".to_string()); let table = lopdf_table::Table::new() .with_style(style) .add_row(lopdf_table::Row::new(vec![lopdf_table::Cell::new("Hello")])); ``` -------------------------------- ### Add lopdf-table to Cargo.toml Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Add the lopdf and lopdf-table dependencies to your Cargo.toml file to use the library. ```toml [dependencies] lopdf = { version = "0.39", features = ["embed_image"] } lopdf-table = "0.5" ``` -------------------------------- ### Render Table to PDF Page with TableDrawing Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Draw a configured table onto a specified PDF page at given coordinates. This method does not handle pagination and the table will be clipped to the page boundaries. ```rust use lopdf::{Document, Object, dictionary}; use lopdf_table::{Table, Row, Cell, TableDrawing}; let mut doc = Document::with_version("1.5"); // … set up pages_id, page_id, font resources, catalog (see full example below) … let table = Table::new() .with_border(1.0) .add_row(Row::new(vec![Cell::new("Name").bold(), Cell::new("Score").bold()])) .add_row(Row::new(vec![Cell::new("Alice"), Cell::new("98")])) .add_row(Row::new(vec![Cell::new("Bob"), Cell::new("87")])); // Draw at PDF point (50, 750) — origin is bottom-left in PDF coordinate space doc.draw_table(page_id, table, (50.0, 750.0)) .expect("table draw failed"); doc.save("output.pdf").unwrap(); ``` -------------------------------- ### Build Table Rows with Row::new Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Group cells into rows using Row::new. Rows can have custom styles, such as background color, and explicit heights. ```rust use lopdf_table::{Row, Cell, RowStyle, Color}; // Alternating background color pattern let even_row = Row::new(vec![ Cell::new("Jane Smith"), Cell::new("Marketing"), Cell::new("$85,000"), ]) .with_style(RowStyle { background_color: Some(Color::rgb(0.95, 0.95, 0.95)), ..Default::default() }); // Explicit row height (useful for image rows) let tall_row = Row::new(vec![Cell::new("Data")]) .with_height(60.0); ``` -------------------------------- ### Set Custom Column Widths Source: https://github.com/fourbs-group/lopdf-table/blob/main/README.md Defines specific widths for table columns using a vector of floating-point numbers. The order of widths corresponds to the order of columns in the table. ```rust let table = Table::new() .add_row(Row::new(vec![...])) .with_column_widths(vec![100.0, 200.0, 150.0]); ``` -------------------------------- ### Draw Table with Accessibility Hooks in Rust Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Implement `TaggedCellHook` to inject custom PDF operations, such as accessibility tags, around each cell during table rendering. This allows for PDF/UA compliance. Requires a `Document` instance, page ID, table, and a hook implementation. ```rust use lopdf::content::Operation; use lopdf::Object; use lopdf_table::{Table, Row, Cell, TableDrawing, TaggedCellHook}; struct AccessibilityHook; impl TaggedCellHook for AccessibilityHook { fn begin_cell(&mut self, _row: usize, _col: usize, is_header: bool) -> Vec { vec![Operation::new( "BDC", vec![ Object::Name(if is_header { b"TH".to_vec() } else { b"TD".to_vec() }), Object::Dictionary(lopdf::dictionary! { "MCID" => 0 }), ], )] } fn end_cell(&mut self, _row: usize, _col: usize, _is_header: bool) -> Vec { vec![Operation::new("EMC", vec![])] } } let table = Table::new() .with_header_rows(1) .add_row(Row::new(vec![Cell::new("Header 1").bold(), Cell::new("Header 2").bold()])) .add_row(Row::new(vec![Cell::new("Data A"), Cell::new("Data B") ])); let mut hook = AccessibilityHook; doc.draw_table_with_hook(page_id, table, (50.0, 750.0), Some(&mut hook)) .expect("tagged draw failed"); ``` -------------------------------- ### Create Table Content Operations in Rust Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Use `create_table_content` to generate raw PDF operations for a table without directly rendering it to a document. This is useful for integrating table content into custom content streams. This method rejects tables with image cells. ```rust use lopdf_table::{Table, Row, Cell, TableDrawing}; use lopdf::Document; let table = Table::new() .with_border(0.5) .add_row(Row::new(vec![Cell::new("Col A").bold(), Cell::new("Col B").bold()])) .add_row(Row::new(vec![Cell::new("1"), Cell::new("2") ])); let objects = Document::with_version("1.7") .create_table_content(&table, (50.0, 750.0)) .expect("content generation failed"); println!("Generated {} PDF objects", objects.len()); // Append `objects` to a custom content stream as needed ``` -------------------------------- ### TableDrawing::draw_table_with_pagination Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Renders a table with automatic page breaks, repeating header rows on each continuation page. It returns a PagedTableResult containing page IDs, total page count, and the final pen position. ```APIDOC ## `TableDrawing::draw_table_with_pagination` — Render with automatic page breaks Splits the table across as many pages as needed, repeating header rows on each continuation page. Returns `PagedTableResult` with all page IDs, total page count, and the final pen position. ```rust use lopdf_table::{ Table, Row, Cell, ColumnWidth, TableDrawing, TableStyle, Color, Alignment, CellStyle, RowStyle, PagedTableResult, }; let mut style = TableStyle::default(); style.page_height = Some(842.0); // A4 style.top_margin = 50.0; style.bottom_margin = 50.0; style.repeat_headers = true; let header_cell_style = CellStyle { text_color: Color::white(), bold: true, alignment: Alignment::Center, ..Default::default() }; let mut table = Table::new() .with_style(style) .with_header_rows(2) .with_column_widths(vec![ ColumnWidth::Pixels(60.0), ColumnWidth::Pixels(150.0), ColumnWidth::Auto, ColumnWidth::Pixels(80.0), ]) .with_total_width(500.0) // Title row spanning all 4 columns .add_row( Row::new(vec![Cell::new("Employee Report").bold().with_colspan(4)]) .with_style(RowStyle { background_color: Some(Color::rgb(0.15, 0.25, 0.45)), ..Default::default() }), ) // Column header row .add_row( Row::new(vec![ Cell::new("ID").with_style(header_cell_style.clone()), Cell::new("Name").with_style(header_cell_style.clone()), Cell::new("Department").with_style(header_cell_style.clone()), Cell::new("Salary").with_style(header_cell_style.clone()), ]) .with_style(RowStyle { background_color: Some(Color::rgb(0.2, 0.3, 0.5)), ..Default::default() }), ); for i in 1..=50 { table = table.add_row(Row::new(vec![ Cell::new(format!("E{i:03}")), Cell::new(format!("Employee {i}")), Cell::new("Engineering"), Cell::new(format!("${}", 50000 + i * 1000)) // Corrected format string .with_style(CellStyle { alignment: Alignment::Right, ..Default::default() }), ])); } let result: PagedTableResult = doc.draw_table_with_pagination(first_page_id, table, (50.0, 750.0)) .expect("paginated draw failed"); println!("Rendered {} pages, final pos: {:?}", result.total_pages, result.final_position); doc.save("report.pdf").unwrap(); ``` ``` -------------------------------- ### TableStyle - Global table appearance Source: https://context7.com/fourbs-group/lopdf-table/llms.txt TableStyle sets borders, fonts, padding, page geometry, and embedded font resource names for the entire table. It provides default values for all table elements. ```APIDOC ## `TableStyle` — Global table appearance `TableStyle` sets borders, fonts, padding, page geometry, and embedded font resource names for the entire table. ```rust use lopdf_table::{TableStyle, Color, BorderStyle, style::Padding}; let mut style = TableStyle::default(); style.border_width = 2.0; style.border_color = Color::rgb(0.2, 0.3, 0.5); style.default_font_size = 11.0; style.font_name = "Times-Roman".to_string(); style.padding = Padding::symmetric(6.0, 8.0); style.page_height = Some(842.0); // A4 style.top_margin = 50.0; style.bottom_margin = 50.0; style.repeat_headers = true; // Embedded TrueType font resource (for Unicode rendering) style.embedded_font_resource_name = Some("EF0".to_string()); style.embedded_font_resource_name_bold = Some("EF0B".to_string()); let table = lopdf_table::Table::new() .with_style(style) .add_row(lopdf_table::Row::new(vec![lopdf_table::Cell::new("Hello") ])); ``` ``` -------------------------------- ### Apply Per-Cell Styles with CellStyle Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Override default table styles for individual cells, including background and text colors, font properties, alignment, and borders. Provides a predefined header style. ```rust use lopdf_table::{CellStyle, Color, Alignment, VerticalAlignment, BorderStyle, style::Padding}; let cell_style = CellStyle { background_color: Some(Color::rgb(0.98, 0.94, 0.84)), text_color: Color::rgb(0.1, 0.1, 0.4), font_size: Some(9.0), font_name: Some("Courier".to_string()), bold: false, italic: true, alignment: Alignment::Center, vertical_alignment: VerticalAlignment::Bottom, padding: Some(Padding::symmetric(4.0, 6.0)), border_top: Some((BorderStyle::Solid, 1.5, Color::rgb(0.5, 0.0, 0.0))), border_bottom: Some((BorderStyle::Dashed, 1.0, Color::black())), ..Default::default() }; // Predefined header style: bold, centered, light-gray background let header_style = CellStyle::header(); ``` -------------------------------- ### Enable Automatic Text Wrapping in Cells Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Use `Cell::with_wrap(true)` to enable word-wrap for long text within a cell. This automatically reflows text to fit the column width, adjusting row height as needed. Explicit newlines are handled independently. ```rust use lopdf_table::{Table, Row, Cell, ColumnWidth}; let table = Table::new() .with_border(1.0) .with_column_widths(vec![ ColumnWidth::Pixels(120.0), ColumnWidth::Pixels(280.0), ]) .with_total_width(400.0) .add_row(Row::new(vec![ Cell::new("Department").bold(), Cell::new("Description").bold(), ])) .add_row(Row::new(vec![ Cell::new("Engineering"), Cell::new( "The Engineering department focuses on product development, \ software architecture, and maintaining our technical infrastructure." ) .with_wrap(true), ])) // Explicit newlines work independently of wrapping .add_row(Row::new(vec![ Cell::new("Address"), Cell::new("John Doe\n123 Main Street\nNew York, NY 10001"), ])); ``` -------------------------------- ### TableDrawing::draw_table_with_hook Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Renders a table by injecting custom PDF operations around each cell using the TaggedCellHook trait, enabling features like PDF/UA accessibility tags. ```APIDOC ## `TableDrawing::draw_table_with_hook` — Render with tagged-content callbacks Injects custom PDF operations (e.g., PDF/UA accessibility tags) around each cell via the `TaggedCellHook` trait. ```rust use lopdf::content::Operation; use lopdf::Object; use lopdf_table::{Table, Row, Cell, TableDrawing, TaggedCellHook}; struct AccessibilityHook; impl TaggedCellHook for AccessibilityHook { fn begin_cell(&mut self, _row: usize, _col: usize, is_header: bool) -> Vec { vec![Operation::new( "BDC", vec![ Object::Name(if is_header { b"TH".to_vec() } else { b"TD".to_vec() }), Object::Dictionary(lopdf::dictionary! { "MCID" => 0 }), ], )] } fn end_cell(&mut self, _row: usize, _col: usize, _is_header: bool) -> Vec { vec![Operation::new("EMC", vec![])] } } let table = Table::new() .with_header_rows(1) .add_row(Row::new(vec![Cell::new("Header 1").bold(), Cell::new("Header 2").bold()])) .add_row(Row::new(vec![Cell::new("Data A"), Cell::new("Data B")])); let mut hook = AccessibilityHook; doc.draw_table_with_hook(page_id, table, (50.0, 750.0), Some(&mut hook)) .expect("tagged draw failed"); ``` ``` -------------------------------- ### Handle Table Drawing Errors with TableError Source: https://context7.com/fourbs-group/lopdf-table/llms.txt All `TableDrawing` methods return `Result<_, TableError>`. Match on specific `TableError` variants for targeted error handling, such as `InvalidTable`, `LayoutError`, `DrawingError`, `PageNotFound`, or `PdfError`. ```rust use lopdf_table::{TableError, Table, Row, Cell, TableDrawing}; match doc.draw_table(page_id, table, (50.0, 750.0)) { Ok(()) => println!("Table drawn successfully"), Err(TableError::InvalidTable(msg)) => eprintln!("Bad structure: {msg}"), Err(TableError::LayoutError(msg)) => eprintln!("Layout failed: {msg}"), Err(TableError::DrawingError(msg)) => eprintln!("Draw failed: {msg}"), Err(TableError::PageNotFound(id)) => eprintln!("Page {:?} not in document", id), Err(TableError::PdfError(e)) => eprintln!("lopdf error: {e}"), Err(e) => eprintln!("Other error: {e}"), } // validate() checks structure before drawing let mut table = Table::new(); assert!(table.validate().is_err()); // empty table table = table.add_row(Row::new(vec![Cell::new("A"), Cell::new("B")Пожалуйста, предоставьте мне информацию о том, как использовать эту функцию. ])); assert!(table.validate().is_ok()); // Mismatched column count triggers InvalidTable table = table.add_row(Row::new(vec![Cell::new("Only one cell")])); assert!(table.validate().is_err()); ``` -------------------------------- ### TableDrawing::create_table_content Source: https://context7.com/fourbs-group/lopdf-table/llms.txt Generates raw PDF operations for a text-only table without rendering it to the document. This is useful for integrating table content with other PDF elements. ```APIDOC ## `TableDrawing::create_table_content` — Generate PDF operations without rendering Produces raw `lopdf::Object` operations for a text-only table without modifying the document. Useful for combining table output with other content streams. Rejects tables containing image cells. ```rust use lopdf_table::{Table, Row, Cell, TableDrawing}; use lopdf::Document; let table = Table::new() .with_border(0.5) .add_row(Row::new(vec![Cell::new("Col A").bold(), Cell::new("Col B").bold()])) .add_row(Row::new(vec![Cell::new("1"), Cell::new("2")])); let objects = Document::with_version("1.7") .create_table_content(&table, (50.0, 750.0)) .expect("content generation failed"); println!("Generated {} PDF objects", objects.len()); // Append `objects` to a custom content stream as needed ``` ``` -------------------------------- ### CellStyle - Per-cell appearance overrides Source: https://context7.com/fourbs-group/lopdf-table/llms.txt CellStyle overrides font, colors, alignment, padding, and individual borders for a single cell. It allows for fine-grained control over the appearance of specific cells. ```APIDOC ## `CellStyle` — Per-cell appearance overrides `CellStyle` overrides font, colors, alignment, padding, and individual borders for a single cell. ```rust use lopdf_table::{CellStyle, Color, Alignment, VerticalAlignment, BorderStyle, style::Padding}; let cell_style = CellStyle { background_color: Some(Color::rgb(0.98, 0.94, 0.84)), text_color: Color::rgb(0.1, 0.1, 0.4), font_size: Some(9.0), font_name: Some("Courier".to_string()), bold: false, italic: true, alignment: Alignment::Center, vertical_alignment: VerticalAlignment::Bottom, padding: Some(Padding::symmetric(4.0, 6.0)), border_top: Some((BorderStyle::Solid, 1.5, Color::rgb(0.5, 0.0, 0.0))), border_bottom: Some((BorderStyle::Dashed, 1.0, Color::black())), ..Default::default() }; // Predefined header style: bold, centered, light-gray background let header_style = CellStyle::header(); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.