table

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package table implements a PDF table component with colspan, rowspan, and per-cell styling.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTableSpanOverlap is returned when colspan/rowspan cells overlap each other.
	ErrTableSpanOverlap = errors.New("table: cell spans overlap")
	// ErrTableEmpty is returned when the cell matrix is empty.
	ErrTableEmpty = errors.New("table: empty cell matrix")
)

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Content       core.Component
	Colspan       int
	Rowspan       int
	Style         *props.Cell
	Height        float64 // explicit outer cell height in mm; used as a row-height floor
	VerticalAlign string
	// ContinuationPaddingTop overrides top padding only after this cell splits.
	ContinuationPaddingTop float64
	// CarryContentNearPageEnd moves content to the next page when a fitting
	// row has less than this much space left at the bottom of the page.
	CarryContentNearPageEnd float64
}

Cell is one entry in the table grid.

type Option

type Option func(*Table)

Option configures a Table.

func WithAlign added in v0.2.2

func WithAlign(align string) Option

WithAlign positions a preferred-width table inside a wider parent cell.

func WithBorderCollapse added in v0.2.2

func WithBorderCollapse(collapse bool) Option

WithBorderCollapse merges adjacent cell borders, matching CSS border-collapse: collapse. Interior cell edges are drawn once instead of twice; border-spacing is ignored by CSS in this mode.

func WithBorderSpacing added in v0.2.2

func WithBorderSpacing(x, y float64) Option

WithBorderSpacing reserves horizontal and vertical spacing between table cells, matching CSS border-spacing for separate-border tables.

func WithColumnWidths

func WithColumnWidths(widths []float64) Option

WithColumnWidths configures relative column widths. Values are normalized to fractions that sum to 1. Non-positive or missing values fall back to the average explicit width so partially specified tables remain usable.

func WithWidth added in v0.2.2

func WithWidth(width float64) Option

WithWidth sets a preferred rendered table width in millimetres. When the parent cell is wider, the table uses this width; when the parent is narrower, it clamps to the parent width.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table is a core.Component that renders a grid with span support.

func New

func New(cells [][]Cell, opts ...Option) (*Table, error)

New validates spans, normalises the grid, and builds the Table component.

func (*Table) ColCount

func (t *Table) ColCount() int

ColCount returns the number of columns determined from the normalised grid.

func (*Table) ColumnWidths

func (t *Table) ColumnWidths() []float64

ColumnWidths returns normalized column width fractions, or nil for equal widths.

func (*Table) GetHeight

func (t *Table) GetHeight(provider core.Provider, cell *entity.Cell) float64

GetHeight computes and returns the total table height.

func (*Table) GetStructure

func (t *Table) GetStructure() *node.Node[core.Structure]

GetStructure returns the component node for snapshots/debugging.

func (*Table) Render

func (t *Table) Render(provider core.Provider, cell *entity.Cell)

Render draws the table into the PDF cell.

func (*Table) SetConfig

func (t *Table) SetConfig(config *entity.Config)

SetConfig propagates Paper config to all cell components.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL