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

This commit is contained in:
Mike Schwörer 2024-05-20 00:52:49 +02:00
parent 194ea4ace5
commit 59963adf74
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 15 additions and 3 deletions

View File

@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.460" const GoextVersion = "0.0.461"
const GoextVersionTimestamp = "2024-05-20T00:38:04+0200" const GoextVersionTimestamp = "2024-05-20T00:52:49+0200"

View File

@ -126,6 +126,10 @@ func (b *WPDFBuilder) SetX(x float64) {
b.b.SetX(x) b.b.SetX(x)
} }
func (b *WPDFBuilder) IncX(dx float64) {
b.b.SetX(b.b.GetX() + dx)
}
func (b *WPDFBuilder) GetX() float64 { func (b *WPDFBuilder) GetX() float64 {
return b.b.GetX() return b.b.GetX()
} }

View File

@ -20,6 +20,7 @@ type PDFCellOpt struct {
textColor *PDFColor textColor *PDFColor
borderColor *PDFColor borderColor *PDFColor
fillColor *PDFColor fillColor *PDFColor
autoWidthPaddingX *float64
} }
func NewPDFCellOpt() *PDFCellOpt { func NewPDFCellOpt() *PDFCellOpt {
@ -113,6 +114,11 @@ func (opt *PDFCellOpt) AutoWidth() *PDFCellOpt {
return opt return opt
} }
func (opt *PDFCellOpt) AutoWidthPaddingX(v float64) *PDFCellOpt {
opt.autoWidthPaddingX = &v
return opt
}
func (opt *PDFCellOpt) TextColor(cr, cg, cb int) *PDFCellOpt { func (opt *PDFCellOpt) TextColor(cr, cg, cb int) *PDFCellOpt {
opt.textColor = langext.Ptr(rgbToColor(cr, cg, cb)) opt.textColor = langext.Ptr(rgbToColor(cr, cg, cb))
return opt return opt
@ -164,6 +170,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
var textColor *PDFColor var textColor *PDFColor
var borderColor *PDFColor var borderColor *PDFColor
var fillColor *PDFColor var fillColor *PDFColor
autoWidthPaddingX := float64(0)
for _, opt := range opts { for _, opt := range opts {
width = langext.Coalesce(opt.width, width) width = langext.Coalesce(opt.width, width)
@ -183,6 +190,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
textColor = langext.CoalesceOpt(opt.textColor, textColor) textColor = langext.CoalesceOpt(opt.textColor, textColor)
borderColor = langext.CoalesceOpt(opt.borderColor, borderColor) borderColor = langext.CoalesceOpt(opt.borderColor, borderColor)
fillColor = langext.CoalesceOpt(opt.fillColor, fillColor) fillColor = langext.CoalesceOpt(opt.fillColor, fillColor)
autoWidthPaddingX = langext.Coalesce(opt.autoWidthPaddingX, autoWidthPaddingX)
} }
if fontNameOverride != nil || fontStyleOverride != nil || fontSizeOverride != nil { if fontNameOverride != nil || fontStyleOverride != nil || fontSizeOverride != nil {
@ -219,7 +227,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
} }
if autoWidth { if autoWidth {
width = b.b.GetStringWidth(txtTR) width = b.b.GetStringWidth(txtTR) + autoWidthPaddingX
} }
b.b.CellFormat(width, height, txtTR, string(border), int(ln), string(align), fill, link, linkStr) b.b.CellFormat(width, height, txtTR, string(border), int(ln), string(align), fill, link, linkStr)