core

package
Version: v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Header = "Header"
	Footer = "Footer"
	Detail = "Detail"

	// flags
	FlagAutoAddNewPage = "AutoAddNewPage"
	FlagResetPageNo    = "ResetPageNo"
)

需要解决的问题: currY的控制权, 用户 -> 程序 -> 自动化操作 页面的三部分: Header Page Footer

Variables

This section is empty.

Functions

func Register

func Register(size string, config *Config)

Types

type CallBack

type CallBack func(report *Report)

type Cell

type Cell interface {
	GenerateAtomicCell(height float64) (writed, remain int, err error) // 写入的行数, 剩余的行数,错误
	TryGenerateAtomicCell(height float64) (writed, remain int)         // 尝试写入
	GetHeight() (height float64)                                       // 当前cell的height
	GetLastHeight() (height float64)                                   // 最近一次cell的height
}

type Config

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

单位像素

func (*Config) GetEnd

func (config *Config) GetEnd() (x, y float64)

func (*Config) GetStart

func (config *Config) GetStart() (x, y float64)

func (*Config) GetWidthAndHeight

func (config *Config) GetWidthAndHeight() (width, height float64)

type Converter

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

对接 pdf

func (*Converter) AddAtomicCell

func (convert *Converter) AddAtomicCell(cell string)

添加AtomicCell

func (*Converter) AddFont

func (convert *Converter) AddFont()

添加字体

func (*Converter) BackgroundColor

func (convert *Converter) BackgroundColor(line string, elements []string)

func (*Converter) Cell

func (convert *Converter) Cell(line string, elements []string)

单元格 ["C", family, size, x, y, content] // 从(x,y) 位置开始写入content ["CL", x, y, content] // 从(x,y) 位置开始写入content ["CR", x, y, w, content] // 从右往左写入w长度的内容

func (*Converter) CompressLevel

func (convert *Converter) CompressLevel(level int)

func (*Converter) Execute

func (convert *Converter) Execute()

将 Text(写入的, 而不是读入的) -> PDF文件

func (convert *Converter) ExternalLink(line string, elements []string)

外部链接 ["EL", x, y, w, h, content, link] // 从(x,y)开始写入content,并添加外链接

func (*Converter) Font

func (convert *Converter) Font(line string, elements []string)

设置当前文本使用的字体 ["", "family", "style", "size"] style: "" or "U", ("B", "I")(需要字体本身支持)

func (*Converter) GetAutomicCells

func (convert *Converter) GetAutomicCells() []string

获取AtomicCells

func (*Converter) GetBytesPdf

func (convert *Converter) GetBytesPdf() (ret []byte)

func (*Converter) GetXY

func (convert *Converter) GetXY() (x, y float64)

func (*Converter) Grey

func (convert *Converter) Grey(line string, elements []string)

设置笔画的灰度 | 设置填充的灰度 ["GF|GS", grayScale] grayScale: 0.0 到 1.0

func (*Converter) Image

func (convert *Converter) Image(line string, elements []string)

图片 ["I", path, x, y, x1, y2]

func (*Converter) InternalLinkAnchor

func (convert *Converter) InternalLinkAnchor(line string, elements []string)

内部链接, 锚点 ["ILA", x, y, w, h, content, anchor]

func (convert *Converter) InternalLinkLink(line string, elements []string)

内部链接, 链接 ["ILL", x, y, w content, anchor]

func (*Converter) Line

func (convert *Converter) Line(line string, elements []string)

线 ["L", x1, y1, x2, y2] 两点之间的线 ["LH", x1, y1, x2] 水平线 ["LV", x1, y2, y2] 垂直线 ["LT", "dashed|dotted|straight", w] 虚线,点,直线

func (*Converter) LineColor

func (convert *Converter) LineColor(line string, elements []string)

画笔颜色 ["", R, G, B]

func (*Converter) Margin

func (convert *Converter) Margin(line string, eles []string)

辅助方法

func (*Converter) MeasureTextWidth

func (convert *Converter) MeasureTextWidth(text string) float64

func (*Converter) NewPage

func (convert *Converter) NewPage(line string, elements []string)

构建新的页面

func (*Converter) NoCompression

func (convert *Converter) NoCompression()

func (*Converter) Oval

func (convert *Converter) Oval(line string, elements []string)

椭圆 ["", x1, y1, x2, y2]

func (*Converter) Page

func (convert *Converter) Page(line string, elements []string)

PDF文件页面的开始 [P, mm|pt|in, A4, P|L] mm|pt|in 表示的尺寸单位, 毫米,像素,英尺 P|L 表示Portait, Landscape, 表示布局

func (*Converter) ReadFile

func (convert *Converter) ReadFile(fileName string) error

从保存的文件解析AtomicCell

func (*Converter) Rect

func (convert *Converter) Rect(line string, eles []string)

长方形 ["R", x1, y1, x2, y2]

func (*Converter) SetAutomicCells

func (convert *Converter) SetAutomicCells(cells []string)

设置AtomicCells(小心使用)

func (*Converter) SetFont

func (convert *Converter) SetFont(family, style string, size int)

func (*Converter) Start

func (convert *Converter) Start(w float64, h float64)

设置PDF文件基本信息(单位,页面大小)

func (*Converter) TextColor

func (convert *Converter) TextColor(line string, elements []string)

文本颜色 ["", R, G, B] // RGB文本颜色

func (*Converter) WritePdf

func (convert *Converter) WritePdf(filepath string)

type Executor

type Executor func(report *Report)

type Font

type Font struct {
	Family string // 字体名称
	Style  string // 字体风格, 目前支持, "" , "U", "B","I", 其中"B", "I" 需要字体本身定义
	Size   int    // 字体大小
}

type FontMap

type FontMap struct {
	FontName string
	FileName string
}

type List

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

func (*List) Add

func (list *List) Add(value interface{})

func (*List) Get

func (list *List) Get(i int) interface{}

func (*List) GetAsArray

func (list *List) GetAsArray() []interface{}

func (*List) Reset

func (list *List) Reset()

func (*List) Size

func (list *List) Size() int

type Report

type Report struct {
	FisrtPageNeedHeader bool // 首页需要执行页眉
	FisrtPageNeedFooter bool // 首页需要执行页脚
	Vars                map[string]string
	// contains filtered or unexported fields
}

func CreateReport

func CreateReport() *Report

func (*Report) AddCallBack

func (report *Report) AddCallBack(callback CallBack)

func (*Report) AddNewPage

func (report *Report) AddNewPage(resetpageNo bool)

添加新的页面

func (*Report) BackgroundColor

func (report *Report) BackgroundColor(x, y, w, h float64, color string, line string)

color: 背景颜色 line: 是否需要边框线条, "0000"不需要, "1111"需要, "0110" 是需要 TOP,RIGHT 线条

func (*Report) Cell

func (report *Report) Cell(x float64, y float64, content string)

写入字符串内容

func (*Report) CellGray

func (report *Report) CellGray(x float64, y float64, content string, grayScale float64)

func (*Report) CellRight

func (report *Report) CellRight(x float64, y float64, w float64, content string)

func (*Report) CompressLevel

func (report *Report) CompressLevel(level int)

*************************************************************** 压缩级别:

-2 只使用哈夫曼压缩,
-1 默认值, 压缩级别的6
0  不进行压缩,
1  最快的压缩, 但是压缩比率不是最好的
9  最大限度的压缩, 但是执行效率也是最慢的

***************************************************************

func (*Report) Execute

func (report *Report) Execute(filepath string)

写入PDF文件

func (report *Report) ExternalLink(x, y, th float64, content, link string)

外部链接

func (*Report) Font

func (report *Report) Font(fontName string, size int, style string)

注册当前字体

func (*Report) GetAllPageNum

func (report *Report) GetAllPageNum() int

GetAllPageNumGetAllPageNum

func (*Report) GetAtomicCells

func (report *Report) GetAtomicCells() *[]string

获取底层的所有的原子单元内容

func (*Report) GetBytesPdf

func (report *Report) GetBytesPdf() (ret []byte)

获取PDF内容

func (*Report) GetConfig

func (report *Report) GetConfig() Config

func (*Report) GetContentWidthAndHeight

func (report *Report) GetContentWidthAndHeight() (width, height float64)

func (*Report) GetCurrentPageNo

func (report *Report) GetCurrentPageNo() int

获取当前页面编号

func (*Report) GetPageEndXY

func (report *Report) GetPageEndXY() (x, y float64)

func (*Report) GetPageStartXY

func (report *Report) GetPageStartXY() (x, y float64)

func (*Report) GetXY

func (report *Report) GetXY() (x, y float64)

func (*Report) Image

func (report *Report) Image(path string, x1 float64, y1 float64, x2 float64, y2 float64)

图片

func (*Report) InternalLinkAnchor

func (report *Report) InternalLinkAnchor(x, y, th float64, content, anchor string)
func (report *Report) InternalLinkLink(x, y float64, content, anchor string)

func (*Report) Line

func (report *Report) Line(x1 float64, y1 float64, x2 float64, y2 float64)

func (*Report) LineColor

func (report *Report) LineColor(red int, green int, blue int)

func (*Report) LineDefaultColor

func (report *Report) LineDefaultColor()

func (*Report) LineGrayColor

func (report *Report) LineGrayColor(x, y float64, w, h float64, gray float64)

线条灰度

func (*Report) LineH

func (report *Report) LineH(x1 float64, y float64, x2 float64)

func (*Report) LineType

func (report *Report) LineType(ltype string, width float64)

划线

func (*Report) LineV

func (report *Report) LineV(x float64, y1 float64, y2 float64)

func (*Report) LoadCellsFromText

func (report *Report) LoadCellsFromText(filepath string) error

func (*Report) MeasureTextWidth

func (report *Report) MeasureTextWidth(text string) float64

计算文本宽度, 必须先调用 SetFontWithStyle() 或者 SetFont()

func (*Report) NoCompression

func (report *Report) NoCompression()

func (*Report) Oval

func (report *Report) Oval(x1 float64, y1 float64, x2 float64, y2 float64)

func (*Report) Rect

func (report *Report) Rect(x1 float64, y1 float64, x2 float64, y2 float64)

画特定的图形, 目前支持: 长方形, 椭圆两大类

func (*Report) RegisterExecutor

func (report *Report) RegisterExecutor(execuror Executor, name string)

func (*Report) SaveAtomicCellText

func (report *Report) SaveAtomicCellText(filepath string)

保存原子操作单元

func (*Report) SetFont

func (report *Report) SetFont(family string, size int)

func (*Report) SetFontWithStyle

func (report *Report) SetFontWithStyle(family, style string, size int)

设置当前文本字体, 先注册,后设置

func (*Report) SetFonts

func (report *Report) SetFonts(fmap []*FontMap)

设置可用字体

func (*Report) SetMargin

func (report *Report) SetMargin(dx, dy float64)

func (*Report) SetPage

func (report *Report) SetPage(size string, orientation string)

设置页面的尺寸, unit: mm pt in size: A4 LTR, 目前支持常用的两种方式

func (*Report) SetXY

func (report *Report) SetXY(currX, currY float64)

currX, currY, 坐标

func (*Report) TextColor

func (report *Report) TextColor(red int, green int, blue int)

func (*Report) TextDefaultColor

func (report *Report) TextDefaultColor()

设置当前的字体颜色, 线条颜色

func (*Report) Var

func (report *Report) Var(name string, val string)

添加变量

type Scope

type Scope struct {
	Left   float64
	Top    float64
	Right  float64
	Bottom float64
}

当作为Margin的时候, Right无法生效 当作为Border的时候, Bottom无法生效

func NewScope

func NewScope(left, top, right, bottom float64) Scope

func (*Scope) ReplaceBorder

func (scope *Scope) ReplaceBorder()

func (*Scope) ReplaceMarign

func (scope *Scope) ReplaceMarign()

Jump to

Keyboard shortcuts

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