pdftable

package module
v0.0.0-...-b0b44b6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 3 Imported by: 0

README

pdftable

基于 github.com/signintech/gopdf

  • 提供行合并单元格能力
  • 提供自动分页能力
  • 自适应列宽(需设置表头,单行)
  • 自适应单元格高度(不包含表头)
  • 可自定义列宽

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRowData

func NewRowData(r *RowData, c *TableConfig)

Types

type RowData

type RowData struct {
	Value []string
	// contains filtered or unexported fields
}

func (*RowData) AddSubRowData

func (r *RowData) AddSubRowData(subr *RowData, config *TableConfig)

func (*RowData) Draw

func (r *RowData) Draw(sx float64, sy float64, minhigh float64, currentIndex int) (float64, bool, *RowData)

Draw sx, sy 表示该单元的标准起始位置 minhigh 表示父单元所需最小高度,用于父子单元高度一致 currentIndex 表示当前渲染的单元格序号 currentIndex 表示当前行数据的起始列号(从0开始) 返回这一行的最低高度,便于父格子高度调整 返回是否分页,便于父格子渲染 返回切分后的RowData,用于多次渲染

type Table

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

func NewTable

func NewTable(config *TableConfig) *Table

func (*Table) AddRowData

func (t *Table) AddRowData(r *RowData, config *TableConfig)

func (*Table) Draw

func (t *Table) Draw() error

func (*Table) DrawHead

func (t *Table) DrawHead(f func() []float64)

DrawHead 手动渲染头部列表,并返回宽度

func (*Table) SetHead

func (t *Table) SetHead(heads []string)

SetHead 变更默认marginW

type TableConfig

type TableConfig struct {
	// gopdf 对象
	Pdf *gopdf.GoPdf
	// 表格内容默认大小
	DefaultFontSize float64
	DefaultMarginH  float64
	DefaultMarginW  float64
	// 列宽
	HeadsW []float64
	// 新页规格,列宽继承初始页面
	Page gopdf.Rect
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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