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:
@@ -1,6 +1,9 @@
|
||||
package wpdf
|
||||
|
||||
import "gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
import (
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/dataext"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
)
|
||||
|
||||
type PDFCellOpt struct {
|
||||
width *float64
|
||||
@@ -14,6 +17,7 @@ type PDFCellOpt struct {
|
||||
fontNameOverride *PDFFontFamily
|
||||
fontStyleOverride *PDFFontStyle
|
||||
fontSizeOverride *float64
|
||||
alphaOverride *dataext.Tuple[float64, PDFBlendMode]
|
||||
extraLn *float64
|
||||
x *float64
|
||||
autoWidth *bool
|
||||
@@ -149,6 +153,34 @@ func (opt *PDFCellOpt) FillColorHex(c uint32) *PDFCellOpt {
|
||||
return opt
|
||||
}
|
||||
|
||||
func (opt *PDFCellOpt) Alpha(alpha float64, blendMode PDFBlendMode) *PDFCellOpt {
|
||||
opt.alphaOverride = &dataext.Tuple[float64, PDFBlendMode]{V1: alpha, V2: blendMode}
|
||||
return opt
|
||||
}
|
||||
|
||||
func (opt *PDFCellOpt) Copy() *PDFCellOpt {
|
||||
c := *opt
|
||||
return &c
|
||||
}
|
||||
|
||||
func (opt *PDFCellOpt) ToMulti() *PDFMultiCellOpt {
|
||||
return &PDFMultiCellOpt{
|
||||
width: opt.width,
|
||||
height: opt.height,
|
||||
border: opt.border,
|
||||
align: opt.align,
|
||||
fill: opt.fill,
|
||||
fontNameOverride: opt.fontNameOverride,
|
||||
fontStyleOverride: opt.fontStyleOverride,
|
||||
fontSizeOverride: opt.fontSizeOverride,
|
||||
extraLn: opt.extraLn,
|
||||
x: opt.x,
|
||||
textColor: opt.textColor,
|
||||
borderColor: opt.borderColor,
|
||||
fillColor: opt.fillColor,
|
||||
}
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
||||
|
||||
txtTR := b.tr(txt)
|
||||
@@ -164,6 +196,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
||||
var fontNameOverride *PDFFontFamily
|
||||
var fontStyleOverride *PDFFontStyle
|
||||
var fontSizeOverride *float64
|
||||
var alphaOverride *dataext.Tuple[float64, PDFBlendMode]
|
||||
extraLn := float64(0)
|
||||
var x *float64
|
||||
autoWidth := false
|
||||
@@ -184,6 +217,7 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
||||
fontNameOverride = langext.CoalesceOpt(opt.fontNameOverride, fontNameOverride)
|
||||
fontStyleOverride = langext.CoalesceOpt(opt.fontStyleOverride, fontStyleOverride)
|
||||
fontSizeOverride = langext.CoalesceOpt(opt.fontSizeOverride, fontSizeOverride)
|
||||
alphaOverride = langext.CoalesceOpt(opt.alphaOverride, alphaOverride)
|
||||
extraLn = langext.Coalesce(opt.extraLn, extraLn)
|
||||
x = langext.CoalesceOpt(opt.x, x)
|
||||
autoWidth = langext.Coalesce(opt.autoWidth, autoWidth)
|
||||
@@ -222,6 +256,12 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
||||
defer func() { b.SetFillColor(oldColorR, oldColorG, oldColorB) }()
|
||||
}
|
||||
|
||||
if alphaOverride != nil {
|
||||
oldA, oldBMS := b.b.GetAlpha()
|
||||
b.b.SetAlpha(alphaOverride.V1, string(alphaOverride.V2))
|
||||
defer func() { b.b.SetAlpha(oldA, oldBMS) }()
|
||||
}
|
||||
|
||||
if x != nil {
|
||||
b.b.SetX(*x)
|
||||
}
|
||||
|
Reference in New Issue
Block a user