pdf

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStyle = &Style{
	FontName:  "Arial",
	FontSize:  12,
	FontColor: &Color{0, 0, 0},
	Padding:   PaddingDescription{Left: 5, Top: 4, Right: 0, Bottom: 6},
	Align:     'L',
}
View Source
var HeaderStyle = &Style{
	FontName:  "DejaVuBold",
	FontSize:  12,
	FontColor: &Color{0xf7, 0xf7, 0xf7},
	BGColor:   &SAVVA_DARK_COLOR,
	Align:     'C',
	Padding:   PaddingDescription{Left: 5, Top: 4, Right: 5, Bottom: 6},
}

Functions

func FormatValue

func FormatValue(amount *big.Int, decimals int) string

func Value2Float

func Value2Float(v *big.Int, decimals int) float64

Types

type Color

type Color struct {
	R, G, B uint8
}
var SAVVA_COLOR Color = Color{0xff, 0x71, 0x00}
var SAVVA_DARK_COLOR Color = Color{0xc4, 0x80, 0x00}

type Doc

type Doc struct {
	*gopdf.GoPdf
	Locale      string
	CurentPage  int
	UserAddress string
	Sections    []*Section

	Margins                            PaddingDescription
	PageWidth, PageHeight              float64
	Section, SubSection, SubSubSection int
	PrintHeader                        bool

	// data
	History   []data.HistoryRecord
	Sponsored []data.Sponsored

	GetImage func(string) (image.Image, error)
	// contains filtered or unexported fields
}

func NewDoc

func NewDoc(user_addr, locale string) (*Doc, error)

func (*Doc) AddBlankPage

func (doc *Doc) AddBlankPage()

func (*Doc) AssureVertialSpace

func (doc *Doc) AssureVertialSpace(h float64)

func (*Doc) DrawBigImage

func (doc *Doc) DrawBigImage(img image.Image) error

func (*Doc) DrawImageCover

func (doc *Doc) DrawImageCover(img image.Image, x, y, targetW, targetH float64) error

DrawImageCover crops and scales the image to cover the given area.

func (*Doc) EclipseToWidth

func (doc *Doc) EclipseToWidth(s string, width float64) (string, float64)

func (*Doc) EclipseToWidthWithStyle

func (doc *Doc) EclipseToWidthWithStyle(s string, width float64, style *Style) (string, float64)

func (*Doc) Footer

func (doc *Doc) Footer()

func (*Doc) FormatFiat

func (doc *Doc) FormatFiat(value float64) string

func (*Doc) FormatValue

func (doc *Doc) FormatValue(amount *big.Int, decimals int) string

func (*Doc) GetMarginHeight

func (doc *Doc) GetMarginHeight() float64

func (*Doc) GetMarginWidth

func (doc *Doc) GetMarginWidth() float64

func (*Doc) Header

func (doc *Doc) Header()

func (*Doc) MarkDownToPdf

func (doc *Doc) MarkDownToPdf(md string) error

MarkDownToPdf converts Markdown text into PDF content.

func (*Doc) MarkDownToPdfEx

func (doc *Doc) MarkDownToPdfEx(md string, x, y, w, h float64, auto_page bool) error

func (*Doc) NewLine

func (doc *Doc) NewLine()

func (*Doc) NewNLines

func (doc *Doc) NewNLines(n int)

func (*Doc) NewSection

func (doc *Doc) NewSection(title string)

func (*Doc) NewSubSection

func (doc *Doc) NewSubSection(title string)

func (*Doc) NewSubSubSection

func (doc *Doc) NewSubSubSection(title string)

func (*Doc) NextPage

func (doc *Doc) NextPage()

func (*Doc) SetColor

func (doc *Doc) SetColor(c *Color)

func (*Doc) SetDocFont

func (doc *Doc) SetDocFont(fontName string, size float64)

func (*Doc) T

func (doc *Doc) T(key string) string

func (*Doc) TextCentered

func (doc *Doc) TextCentered(text string, x, y float64)

func (*Doc) TextLeft

func (doc *Doc) TextLeft(text string, x, y float64)

func (*Doc) TextRight

func (doc *Doc) TextRight(text string, x, y float64)

func (*Doc) TextWidthStyle

func (doc *Doc) TextWidthStyle(text string, x, y, w float64, style *Style)

func (*Doc) WriteTable

func (doc *Doc) WriteTable(t *Table)

type PaddingDescription

type PaddingDescription struct {
	Left, Top, Right, Bottom float64
}

type Section

type Section struct {
	Title       string
	Page        int
	SubSections []*Section
}

type Style

type Style struct {
	FontName  string
	FontSize  float64
	FontColor *Color
	BGColor   *Color
	Padding   PaddingDescription
	Align     uint8 // 'L', 'C', 'R'
	MinHeight float64
}

type Table

type Table struct {
	Cells            [][]string
	Header           []string
	W, H             int
	ColWidths        []float64
	ColStyle         []Style
	OnBeforeDrawCell func(t *Table, row, col int, x, y float64, w float64, h float64, text string, style *Style)
}

func NewTable

func NewTable() *Table

func (*Table) AddRow

func (t *Table) AddRow(s ...string)

func (*Table) SetHeader

func (t *Table) SetHeader(s ...string)

func (*Table) SetW

func (t *Table) SetW(w int)

Jump to

Keyboard shortcuts

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