Documentation
¶
Index ¶
- Constants
- Variables
- type BorderStyle
- type Cell
- type CellStyle
- func (s *CellStyle) HAlignToEngineString() string
- func (s *CellStyle) SetBorderStyle(style *BorderStyle)
- func (s *CellStyle) SetFillColor(color *RGB)
- func (s *CellStyle) SetFontStyle(style *FontStyle)
- func (s *CellStyle) SetHAlign(align string)
- func (s *CellStyle) SetVAlign(align string)
- func (s *CellStyle) SetupFillColor(p *PDF)
- func (s *CellStyle) ToAlignEngineString() string
- func (s *CellStyle) VAlignToEngineString() string
- type FontStyle
- func (s *FontStyle) SetBold(bold bool)
- func (s *FontStyle) SetFontColor(fontColor *RGB)
- func (s *FontStyle) SetFontFamily(fontFamily string)
- func (s *FontStyle) SetFontSize(fontSize float64)
- func (s *FontStyle) SetLineHeight(lineHeight float64)
- func (s *FontStyle) SetStrikeout(strikeout bool)
- func (s *FontStyle) SetUnderline(underline bool)
- func (s *FontStyle) Setup(pdf *PDF)
- type PDF
- func (p *PDF) AddPage()
- func (p *PDF) LineBreak(style *FontStyle)
- func (p *PDF) SetDefaultFontStyle(style *FontStyle)
- func (p *PDF) ToBytes() []byte
- func (p *PDF) ToFile(filePath string)
- func (p *PDF) WriteImage(imgSrc string, width float64, height float64, flow bool)
- func (p *PDF) WriteImageBytes(imgBytes []byte, width float64, height float64, flow bool)
- func (p *PDF) WriteLink(text string, link string, style *FontStyle)
- func (p *PDF) WriteTable(cells []*Cell, padding *Padding)
- func (p *PDF) WriteText(text string, style *FontStyle)
- func (p *PDF) WriteTextBox(text string, align string, style *FontStyle)
- type Padding
- type Page
- type PageLayout
- type PageMargin
- type RGB
Constants ¶
const ( AlignLeft = "L" AlignCenter = "C" AlignRight = "R" )
const ( AlignTop = "T" AlignMiddle = "M" AlignBottom = "B" AlignBaseline = "A" )
const ( FontFamilyCourier = "Courier" FontFamilyHelvetica = "Helvetica" FontFamilyTimes = "Times" FontFamilySymbol = "Symbol" FontFamilyNotoSansTC = "NotoSansTC" FontFamilyNotoSansSC = "NotoSansSC" )
const ( PaperA3 = "A3" PaperA4 = "A4" PaperA5 = "A5" PaperLetter = "Letter" PaperLegal = "Legal" PaperTabloid = "Tabloid" )
Variables ¶
var ( OrientationPortrait = "P" OrientationLandscape = "L" )
Functions ¶
This section is empty.
Types ¶
type BorderStyle ¶
type BorderStyle struct {
Top bool `json:"top"`
Left bool `json:"left"`
Right bool `json:"right"`
Bottom bool `json:"bottom"`
Color *RGB `json:"color"`
}
func NewBorderStyle ¶
func NewBorderStyle(top, left, right, bottom bool, color *RGB) *BorderStyle
func (*BorderStyle) BorderToEngineString ¶
func (s *BorderStyle) BorderToEngineString() string
func (*BorderStyle) SetupBorderColor ¶
func (s *BorderStyle) SetupBorderColor(p *PDF)
type Cell ¶
type Cell struct {
Text string `json:"text"`
Style *CellStyle `json:"style"`
Width float64 `json:"width"`
WidthPercent float64 `json:"width_percent"`
}
type CellStyle ¶
type CellStyle struct {
FontStyle *FontStyle `json:"font_style"`
BorderStyle *BorderStyle `json:"border_style"`
FillColor *RGB `json:"fill_color"`
HAlign string `json:"h_align"`
VAlign string `json:"v_align"`
}
func NewCellStyle ¶
func NewCellStyle(fontStyle *FontStyle, borderStyle *BorderStyle, fillColor *RGB, hAlign, vAlign string) *CellStyle
func (*CellStyle) HAlignToEngineString ¶
func (*CellStyle) SetBorderStyle ¶
func (s *CellStyle) SetBorderStyle(style *BorderStyle)
func (*CellStyle) SetFillColor ¶
func (*CellStyle) SetFontStyle ¶
func (*CellStyle) SetupFillColor ¶
func (*CellStyle) ToAlignEngineString ¶
func (*CellStyle) VAlignToEngineString ¶
type FontStyle ¶
type FontStyle struct {
FontFamily string `json:"font_family"`
FontSize float64 `json:"font_size"`
LineHeight float64 `json:"line_height"`
FontColor *RGB `json:"font_color"`
Bold bool `json:"bold"`
Strikeout bool `json:"strikeout"`
Underline bool `json:"underline"`
}
func NewFontStyle ¶
func (*FontStyle) SetBold ¶
SetBold sets the font style to bold. By default, the font style is not bold.
func (*FontStyle) SetFontColor ¶
SetFontColor sets the font color for the PDF. By default, the font color is black.
func (*FontStyle) SetFontFamily ¶
SetFontFamily sets the font family for the PDF. By default, the font family is Helvetica.
func (*FontStyle) SetFontSize ¶
SetFontSize sets the font size for the PDF. By default, the font size is 12.
func (*FontStyle) SetLineHeight ¶
SetLineHeight sets the line height for the PDF. By default, the line height same as the font size.
func (*FontStyle) SetStrikeout ¶
SetStrikeout sets the font style to strikeout. By default, the font style is not strikeout.
func (*FontStyle) SetUnderline ¶
SetUnderline sets the font style to underline. By default, the font style is not underline.
type PDF ¶
type PDF struct {
Engine *gofpdf.Fpdf `json:"-"`
PageLayout *PageLayout `json:"page_layout"`
DefaultFontStyle *FontStyle `json:"default_font_style"`
CurrentPageIndex int `json:"-"`
PageHeight float64 `json:"page_height"`
PageWidth float64 `json:"page_width"`
PageMarginTop float64 `json:"page_margin_top"`
PageMarginBottom float64 `json:"page_margin_bottom"`
PageMarginLeft float64 `json:"page_margin_left"`
PageMarginRight float64 `json:"page_margin_right"`
PageBodyHeight float64 `json:"page_body_height"` // Page height minus top and bottom margins
PageBodyWidth float64 `json:"page_body_width"` // Page width minus left and right margins
}
func New ¶
func New(layout ...*PageLayout) *PDF
func (*PDF) SetDefaultFontStyle ¶
func (*PDF) WriteImage ¶
func (*PDF) WriteImageBytes ¶
func (*PDF) WriteTable ¶
type Padding ¶
type Padding struct {
Top float64 `json:"top"`
Left float64 `json:"left"`
Right float64 `json:"right"`
Bottom float64 `json:"bottom"`
}
func NewPadding ¶
type Page ¶
type Page struct {
PageLayout *PageLayout `json:"page_layout"`
PageHeight float64 `json:"page_height"`
PageWidth float64 `json:"page_width"`
PageMarginTop float64 `json:"page_margin_top"`
PageMarginBottom float64 `json:"page_margin_bottom"`
PageMarginLeft float64 `json:"page_margin_left"`
PageMarginRight float64 `json:"page_margin_right"`
PageBodyHeight float64 `json:"page_body_height"`
PageBodyWidth float64 `json:"page_body_width"`
}
type PageLayout ¶
type PageLayout struct {
Orientation string `json:"orientation"`
Paper string `json:"paper"`
PageMargin *PageMargin `json:"page_margin"`
DefaultFontStyle *FontStyle `json:"default_font_style"`
}
func NewPageLayout ¶
func NewPageLayout(orientation, paper string) *PageLayout
func (*PageLayout) SetOrientation ¶
func (s *PageLayout) SetOrientation(orientation string)
SetOrientation sets the orientation for the PDF. By default, the orientation is portrait.
func (*PageLayout) SetPaper ¶
func (s *PageLayout) SetPaper(paper string)
SetPaper sets the paper size for the PDF. By default, the paper size is A4.
type PageMargin ¶
type PageMargin struct {
Top float64 `json:"top"`
Left float64 `json:"left"`
Right float64 `json:"right"`
Bottom float64 `json:"bottom"`
}
func NewPageMargin ¶
func NewPageMargin(top, left, right, bottom float64) *PageMargin