From 59963adf7449fcc98a43b4ccab95730a75e64c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 20 May 2024 00:52:49 +0200 Subject: [PATCH] v0.0.461 --- goextVersion.go | 4 ++-- wpdf/wpdf.go | 4 ++++ wpdf/wpdfCell.go | 10 +++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/goextVersion.go b/goextVersion.go index 74aa92b..ea413a3 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ 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" diff --git a/wpdf/wpdf.go b/wpdf/wpdf.go index e214f48..6e54c62 100644 --- a/wpdf/wpdf.go +++ b/wpdf/wpdf.go @@ -126,6 +126,10 @@ func (b *WPDFBuilder) SetX(x float64) { b.b.SetX(x) } +func (b *WPDFBuilder) IncX(dx float64) { + b.b.SetX(b.b.GetX() + dx) +} + func (b *WPDFBuilder) GetX() float64 { return b.b.GetX() } diff --git a/wpdf/wpdfCell.go b/wpdf/wpdfCell.go index 3fde986..3b706a4 100644 --- a/wpdf/wpdfCell.go +++ b/wpdf/wpdfCell.go @@ -20,6 +20,7 @@ type PDFCellOpt struct { textColor *PDFColor borderColor *PDFColor fillColor *PDFColor + autoWidthPaddingX *float64 } func NewPDFCellOpt() *PDFCellOpt { @@ -113,6 +114,11 @@ func (opt *PDFCellOpt) AutoWidth() *PDFCellOpt { return opt } +func (opt *PDFCellOpt) AutoWidthPaddingX(v float64) *PDFCellOpt { + opt.autoWidthPaddingX = &v + return opt +} + func (opt *PDFCellOpt) TextColor(cr, cg, cb int) *PDFCellOpt { opt.textColor = langext.Ptr(rgbToColor(cr, cg, cb)) return opt @@ -164,6 +170,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) { var textColor *PDFColor var borderColor *PDFColor var fillColor *PDFColor + autoWidthPaddingX := float64(0) for _, opt := range opts { width = langext.Coalesce(opt.width, width) @@ -183,6 +190,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) { textColor = langext.CoalesceOpt(opt.textColor, textColor) borderColor = langext.CoalesceOpt(opt.borderColor, borderColor) fillColor = langext.CoalesceOpt(opt.fillColor, fillColor) + autoWidthPaddingX = langext.Coalesce(opt.autoWidthPaddingX, autoWidthPaddingX) } if fontNameOverride != nil || fontStyleOverride != nil || fontSizeOverride != nil { @@ -219,7 +227,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) { } 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)