v0.0.460
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m16s

This commit is contained in:
2024-05-20 00:38:04 +02:00
parent 73b80a66bc
commit 194ea4ace5
5 changed files with 129 additions and 6 deletions

View File

@@ -13,6 +13,9 @@ type PDFMultiCellOpt struct {
fontSizeOverride *float64
extraLn *float64
x *float64
textColor *PDFColor
borderColor *PDFColor
fillColor *PDFColor
}
func NewPDFMultiCellOpt() *PDFMultiCellOpt {
@@ -86,6 +89,36 @@ func (opt *PDFMultiCellOpt) X(v float64) *PDFMultiCellOpt {
return opt
}
func (opt *PDFMultiCellOpt) TextColor(cr, cg, cb int) *PDFMultiCellOpt {
opt.textColor = langext.Ptr(rgbToColor(cr, cg, cb))
return opt
}
func (opt *PDFMultiCellOpt) TextColorHex(c uint32) *PDFMultiCellOpt {
opt.textColor = langext.Ptr(hexToColor(c))
return opt
}
func (opt *PDFMultiCellOpt) BorderColor(cr, cg, cb int) *PDFMultiCellOpt {
opt.borderColor = langext.Ptr(rgbToColor(cr, cg, cb))
return opt
}
func (opt *PDFMultiCellOpt) BorderColorHex(c uint32) *PDFMultiCellOpt {
opt.borderColor = langext.Ptr(hexToColor(c))
return opt
}
func (opt *PDFMultiCellOpt) FillColor(cr, cg, cb int) *PDFMultiCellOpt {
opt.fillColor = langext.Ptr(rgbToColor(cr, cg, cb))
return opt
}
func (opt *PDFMultiCellOpt) FillColorHex(c uint32) *PDFMultiCellOpt {
opt.fillColor = langext.Ptr(hexToColor(c))
return opt
}
func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
txtTR := b.tr(txt)
@@ -100,6 +133,9 @@ func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
var fontSizeOverride *float64
extraLn := float64(0)
var x *float64
var textColor *PDFColor
var borderColor *PDFColor
var fillColor *PDFColor
for _, opt := range opts {
width = langext.Coalesce(opt.width, width)
@@ -112,6 +148,9 @@ func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
fontSizeOverride = langext.CoalesceOpt(opt.fontSizeOverride, fontSizeOverride)
extraLn = langext.Coalesce(opt.extraLn, extraLn)
x = langext.CoalesceOpt(opt.x, x)
textColor = langext.CoalesceOpt(opt.textColor, textColor)
borderColor = langext.CoalesceOpt(opt.borderColor, borderColor)
fillColor = langext.CoalesceOpt(opt.fillColor, fillColor)
}
if fontNameOverride != nil || fontStyleOverride != nil || fontSizeOverride != nil {
@@ -125,6 +164,24 @@ func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
defer func() { b.SetFont(oldFontName, oldFontStyle, oldFontSize) }()
}
if textColor != nil {
oldColorR, oldColorG, oldColorB := b.b.GetTextColor()
b.SetTextColor(textColor.R, textColor.G, textColor.B)
defer func() { b.SetTextColor(oldColorR, oldColorG, oldColorB) }()
}
if borderColor != nil {
oldColorR, oldColorG, oldColorB := b.b.GetDrawColor()
b.SetDrawColor(borderColor.R, borderColor.G, borderColor.B)
defer func() { b.SetDrawColor(oldColorR, oldColorG, oldColorB) }()
}
if fillColor != nil {
oldColorR, oldColorG, oldColorB := b.b.GetFillColor()
b.SetFillColor(fillColor.R, fillColor.G, fillColor.B)
defer func() { b.SetFillColor(oldColorR, oldColorG, oldColorB) }()
}
if x != nil {
b.b.SetX(*x)
}