Documentation ¶
Index ¶
- Constants
- func Register(size string, config *Config)
- type CallBack
- type Cell
- type Config
- type Converter
- func (convert *Converter) AddAtomicCell(cell string)
- func (convert *Converter) AddFont()
- func (convert *Converter) BackgroundColor(line string, elements []string)
- func (convert *Converter) Cell(line string, elements []string)
- func (convert *Converter) CompressLevel(level int)
- func (convert *Converter) Execute()
- func (convert *Converter) ExternalLink(line string, elements []string)
- func (convert *Converter) Font(line string, elements []string)
- func (convert *Converter) GetAutomicCells() []string
- func (convert *Converter) GetBytesPdf() (ret []byte)
- func (convert *Converter) GetXY() (x, y float64)
- func (convert *Converter) Grey(line string, elements []string)
- func (convert *Converter) Image(line string, elements []string)
- func (convert *Converter) InternalLinkAnchor(line string, elements []string)
- func (convert *Converter) InternalLinkLink(line string, elements []string)
- func (convert *Converter) Line(line string, elements []string)
- func (convert *Converter) LineColor(line string, elements []string)
- func (convert *Converter) Margin(line string, eles []string)
- func (convert *Converter) MeasureTextWidth(text string) float64
- func (convert *Converter) NewPage(line string, elements []string)
- func (convert *Converter) NoCompression()
- func (convert *Converter) Oval(line string, elements []string)
- func (convert *Converter) Page(line string, elements []string)
- func (convert *Converter) ReadFile(fileName string) error
- func (convert *Converter) Rect(line string, eles []string)
- func (convert *Converter) SetAutomicCells(cells []string)
- func (convert *Converter) SetFont(family, style string, size int)
- func (convert *Converter) TextColor(line string, elements []string)
- func (convert *Converter) WritePdf(filepath string)
- type Executor
- type Font
- type FontMap
- type List
- type Report
- func (report *Report) AddCallBack(callback CallBack)
- func (report *Report) AddNewPage(resetpageNo bool)
- func (report *Report) BackgroundColor(x, y, w, h float64, bgcolor string, lines string, lcolor ...string)
- func (report *Report) Cell(x float64, y float64, content string)
- func (report *Report) CellGray(x float64, y float64, content string, grayScale float64)
- func (report *Report) CellRight(x float64, y float64, w float64, content string)
- func (report *Report) CompressLevel(level int)
- func (report *Report) Execute(filepath string)
- func (report *Report) ExternalLink(x, y, th float64, content, link string)
- func (report *Report) Font(fontName string, size int, style string)
- func (report *Report) GetAtomicCells() *[]string
- func (report *Report) GetBytesPdf() (ret []byte)
- func (report *Report) GetConfig() Config
- func (report *Report) GetContentWidthAndHeight() (width, height float64)
- func (report *Report) GetCurrentPageNo() int
- func (report *Report) GetPageEndXY() (x, y float64)
- func (report *Report) GetPageStartXY() (x, y float64)
- func (report *Report) GetXY() (x, y float64)
- func (report *Report) Image(path string, x1 float64, y1 float64, x2 float64, y2 float64)
- func (report *Report) InternalLinkAnchor(x, y, th float64, content, anchor string)
- func (report *Report) InternalLinkLink(x, y float64, content, anchor string)
- func (report *Report) Line(x1 float64, y1 float64, x2 float64, y2 float64)
- func (report *Report) LineColor(red int, green int, blue int)
- func (report *Report) LineDefaultColor()
- func (report *Report) LineGrayColor(x, y float64, w, h float64, gray float64)
- func (report *Report) LineH(x1 float64, y float64, x2 float64)
- func (report *Report) LineType(ltype string, width float64)
- func (report *Report) LineV(x float64, y1 float64, y2 float64)
- func (report *Report) LoadCellsFromText(filepath string) error
- func (report *Report) MeasureTextWidth(text string) float64
- func (report *Report) NoCompression()
- func (report *Report) Oval(x1 float64, y1 float64, x2 float64, y2 float64)
- func (report *Report) Rect(x1 float64, y1 float64, x2 float64, y2 float64)
- func (report *Report) RegisterExecutor(execuror Executor, name string)
- func (report *Report) SaveAtomicCellText(filepath string)
- func (report *Report) SetFont(family string, size int)
- func (report *Report) SetFontWithStyle(family, style string, size int)
- func (report *Report) SetFonts(fmap []*FontMap)
- func (report *Report) SetMargin(dx, dy float64)
- func (report *Report) SetPage(size string, orientation string)
- func (report *Report) SetXY(currX, currY float64)
- func (report *Report) TextColor(red int, green int, blue int)
- func (report *Report) TextDefaultColor()
- func (report *Report) Var(name string, val string)
- type Scope
Constants ¶
const ( // A PDF page is divided into three parts, the header(Header), the footer(Footer) and // the main body(Detail). // // Each part has its own executor. The main actuator is necessary because it is the most // important content that constitutes the PDF page. Header = "Header" Detail = "Detail" // flags Flag_AutoAddNewPage = "AutoAddNewPage" Flag_ResetPageNo = "ResetPageNo" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
the units of below is pixels.
func NewConfig ¶
Params width, height is pdf page width and height Params padingH, padingV is pdf horizontal and vertical padding The units of the above parameters are pixels. Params width must more than 2*padingH, and height must more 2*padingV
func (*Config) GetStart ¶
Get pdf page start position, from the position you can write the pdf body content.
func (*Config) GetWidthAndHeight ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter is a bridge to third-party gopdf. The content generated by the user by calling a simple interface is converted from pdf to complex content, and finally a pdf file is generated.
func (*Converter) AddAtomicCell ¶
Add a atomicCell to atomicCells
func (*Converter) BackgroundColor ¶
backgroup color
func (*Converter) Cell ¶
Clell ["C", family, size, x, y, content] // Start writing text from position (x,y) ["CL", x, y, content] // Start writing text from position (x,y) ["CR", x, y, w, content] // Write text of w length from right to left
func (*Converter) CompressLevel ¶
func (*Converter) Execute ¶
func (convert *Converter) Execute()
Generate a pdf file of the content recorded in atomicCells.
func (*Converter) ExternalLink ¶
external link ["EL", x, y, w, h, content, link] // Start writing text from (x,y) and add external links
func (*Converter) Font ¶
Set Font used for the current text ["", "family", "style", "size"] style: "" or "U", ("B", "I")("B" means "Bold", "I" means "Italic", these font self support)
func (*Converter) GetAutomicCells ¶
GetAtomicCells, get atomicCells
func (*Converter) GetBytesPdf ¶
func (*Converter) Grey ¶
Set the gray scale of the stroke Or Set the gray scale of the fill ["GF|GS", grayScale] grayScale: 0.0 到 1.0
func (*Converter) InternalLinkAnchor ¶
Internal link, anchor ["ILA", x, y, w, h, content, anchor]
func (*Converter) InternalLinkLink ¶
Internal link, link ["ILL", x, y, w content, anchor]
func (*Converter) Line ¶
line ["L", x1, y1, x2, y2], Line between any two points ["LH", x1, y1, x2], Horizontal line ["LV", x1, y2, y2], Vertical line
["LT", "dashed|dotted|straight", w] Lines with a specific style(dashed,dotted,straight) dashed: ---- dotted: .... straight: ___
func (*Converter) MeasureTextWidth ¶
func (*Converter) NoCompression ¶
func (convert *Converter) NoCompression()
func (*Converter) Page ¶
Page [P, mm|pt|in, A4, P|L] mm|pt|in, Indicates the unit of size, respectively representing millimeters, pixels, and feet P|L, Page layout, namely Portait, Landscape
func (*Converter) ReadFile ¶
ReadFile parse file content to atomicCells Generate pdf files for text content from already saved atomicCells, generally used for debugging.
func (*Converter) SetAutomicCells ¶
SetAtomicCells, set atomicCells (use caution)
type List ¶
type List struct {
// contains filtered or unexported fields
}
func (*List) GetAsArray ¶
func (list *List) GetAsArray() []interface{}
type Report ¶
type Report struct { FisrtPageNeedHeader bool // Wheather the first page need to execute the header Vars map[string]string // contains filtered or unexported fields }
func CreateReport ¶
func CreateReport() *Report
func (*Report) AddCallBack ¶
func (*Report) BackgroundColor ¶
func (report *Report) BackgroundColor(x, y, w, h float64, bgcolor string, lines string, lcolor ...string)
bgcolor: background color. style is "r,g,b", eg. "1,1,1" is black lines: whether border lines are needed. eg, "0000" is not needed, "1111" is needed, "0110" is required for TOP, RIGHT lines. lcolor: line color, style is "r,g,b", eg. "1,1,1" is black
func (*Report) CompressLevel ¶
*************************************************************** Compression level:
-2: Only Huffman compression is used, -1: Default value, compression level 6 0: Not compress, 1: The fastest compression, but the compression ratio is not the best 9: Maximum compression, but the execution efficiency is also the slowest
***************************************************************
func (*Report) ExternalLink ¶
外部链接
func (*Report) GetBytesPdf ¶
GetBytesPdf, get PDF file content
func (*Report) GetContentWidthAndHeight ¶
func (*Report) GetPageEndXY ¶
func (*Report) GetPageStartXY ¶
func (*Report) InternalLinkAnchor ¶
func (*Report) InternalLinkLink ¶
func (*Report) LineDefaultColor ¶
func (report *Report) LineDefaultColor()
func (*Report) LineGrayColor ¶
线条灰度
func (*Report) LoadCellsFromText ¶
LoadCellsFromText, generate PDF file from cells file
func (*Report) MeasureTextWidth ¶
计算文本宽度, 必须先调用 SetFontWithStyle() 或者 SetFont()
func (*Report) NoCompression ¶
func (report *Report) NoCompression()
func (*Report) RegisterExecutor ¶
func (*Report) SaveAtomicCellText ¶
保存原子操作单元
func (*Report) SetFontWithStyle ¶
设置当前文本字体, 先注册,后设置
type Scope ¶
When used as Margin, Right cannot take effect When used as a Border, Bottom cannot take effect
func (*Scope) ReplaceBorder ¶
func (scope *Scope) ReplaceBorder()
func (*Scope) ReplaceMarign ¶
func (scope *Scope) ReplaceMarign()