v0.0.494 add tables to wpdf
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
This commit is contained in:
49
wpdf/wpdf.go
49
wpdf/wpdf.go
@@ -3,6 +3,7 @@ package wpdf
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/jung-kurt/gofpdf"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
)
|
||||
|
||||
type WPDFBuilder struct {
|
||||
@@ -105,6 +106,18 @@ func (b *WPDFBuilder) SetFont(fontName PDFFontFamily, fontStyle PDFFontStyle, fo
|
||||
b.cellHeight = b.b.PointConvert(fontSize)
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) GetFontSize() float64 {
|
||||
return b.fontSize
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) GetFontFamily() PDFFontStyle {
|
||||
return b.fontStyle
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) GetFontStyle() float64 {
|
||||
return b.fontSize
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) SetCellSpacing(h float64) {
|
||||
b.cellSpacing = h
|
||||
}
|
||||
@@ -192,6 +205,40 @@ func (b *WPDFBuilder) GetWorkAreaWidth() float64 {
|
||||
return b.GetPageWidth() - b.GetMarginLeft() - b.GetMarginRight()
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) GetStringWidth(str string) float64 {
|
||||
func (b *WPDFBuilder) SetAutoPageBreak(auto bool, margin float64) {
|
||||
b.b.SetAutoPageBreak(auto, margin)
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) SetFooterFunc(fnc func()) {
|
||||
b.b.SetFooterFunc(fnc)
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) PageNo() int {
|
||||
return b.b.PageNo()
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) GetStringWidth(str string, opts ...PDFCellOpt) float64 {
|
||||
|
||||
var fontNameOverride *PDFFontFamily
|
||||
var fontStyleOverride *PDFFontStyle
|
||||
var fontSizeOverride *float64
|
||||
|
||||
for _, opt := range opts {
|
||||
fontNameOverride = langext.CoalesceOpt(opt.fontNameOverride, fontNameOverride)
|
||||
fontStyleOverride = langext.CoalesceOpt(opt.fontStyleOverride, fontStyleOverride)
|
||||
fontSizeOverride = langext.CoalesceOpt(opt.fontSizeOverride, fontSizeOverride)
|
||||
}
|
||||
|
||||
if fontNameOverride != nil || fontStyleOverride != nil || fontSizeOverride != nil {
|
||||
oldFontName := b.fontName
|
||||
oldFontStyle := b.fontStyle
|
||||
oldFontSize := b.fontSize
|
||||
newFontName := langext.Coalesce(fontNameOverride, oldFontName)
|
||||
newFontStyle := langext.Coalesce(fontStyleOverride, oldFontStyle)
|
||||
newFontSize := langext.Coalesce(fontSizeOverride, oldFontSize)
|
||||
b.SetFont(newFontName, newFontStyle, newFontSize)
|
||||
defer func() { b.SetFont(oldFontName, oldFontStyle, oldFontSize) }()
|
||||
}
|
||||
|
||||
return b.b.GetStringWidth(str)
|
||||
}
|
||||
|
Reference in New Issue
Block a user