Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
62980e1489
|
|||
59963adf74
|
|||
194ea4ace5
|
@@ -72,20 +72,22 @@ func NewEngine(opt Options) *GinWrapper {
|
|||||||
engine.Use(CorsMiddleware())
|
engine.Use(CorsMiddleware())
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not debug-print routes
|
if wrapper.ginDebug {
|
||||||
gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {}
|
gin.SetMode(gin.DebugMode)
|
||||||
|
|
||||||
if !wrapper.ginDebug {
|
// do not debug-print routes
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {}
|
||||||
|
|
||||||
if !wrapper.suppressGinLogs {
|
if !wrapper.suppressGinLogs {
|
||||||
ginlogger := gin.Logger()
|
ginlogger := gin.Logger()
|
||||||
engine.Use(func(context *gin.Context) {
|
engine.Use(func(context *gin.Context) { ginlogger(context) })
|
||||||
ginlogger(context)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
gin.SetMode(gin.DebugMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
|
||||||
|
// do not debug-print routes
|
||||||
|
gin.DebugPrintRouteFunc = func(_, _, _ string, _ int) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
6
go.mod
6
go.mod
@@ -7,7 +7,7 @@ require (
|
|||||||
github.com/glebarez/go-sqlite v1.22.0 // only needed for tests -.-
|
github.com/glebarez/go-sqlite v1.22.0 // only needed for tests -.-
|
||||||
github.com/jmoiron/sqlx v1.4.0
|
github.com/jmoiron/sqlx v1.4.0
|
||||||
github.com/rs/xid v1.5.0
|
github.com/rs/xid v1.5.0
|
||||||
github.com/rs/zerolog v1.32.0
|
github.com/rs/zerolog v1.33.0
|
||||||
go.mongodb.org/mongo-driver v1.15.0
|
go.mongodb.org/mongo-driver v1.15.0
|
||||||
golang.org/x/crypto v0.23.0
|
golang.org/x/crypto v0.23.0
|
||||||
golang.org/x/sys v0.20.0
|
golang.org/x/sys v0.20.0
|
||||||
@@ -21,7 +21,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bytedance/sonic v1.11.6 // indirect
|
github.com/bytedance/sonic v1.11.7 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||||
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
|
||||||
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
github.com/chenzhuoyu/iasm v0.9.1 // indirect
|
||||||
@@ -33,7 +33,7 @@ require (
|
|||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
github.com/goccy/go-json v0.10.3 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/uuid v1.5.0 // indirect
|
github.com/google/uuid v1.5.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
|
6
go.sum
6
go.sum
@@ -18,6 +18,8 @@ github.com/bytedance/sonic v1.11.5 h1:G00FYjjqll5iQ1PYXynbg/hyzqBqavH8Mo9/oTopd9
|
|||||||
github.com/bytedance/sonic v1.11.5/go.mod h1:X2PC2giUdj/Cv2lliWFLk6c/DUQok5rViJSemeB0wDw=
|
github.com/bytedance/sonic v1.11.5/go.mod h1:X2PC2giUdj/Cv2lliWFLk6c/DUQok5rViJSemeB0wDw=
|
||||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||||
|
github.com/bytedance/sonic v1.11.7 h1:k/l9p1hZpNIMJSk37wL9ltkcpqLfIho1vYthi4xT2t4=
|
||||||
|
github.com/bytedance/sonic v1.11.7/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||||
github.com/bytedance/sonic/loader v0.1.0/go.mod h1:UmRT+IRTGKz/DAkzcEGzyVqQFJ7H9BqwBO3pm9H/+HY=
|
github.com/bytedance/sonic/loader v0.1.0/go.mod h1:UmRT+IRTGKz/DAkzcEGzyVqQFJ7H9BqwBO3pm9H/+HY=
|
||||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||||
@@ -79,6 +81,8 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv
|
|||||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
|
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
|
||||||
|
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
@@ -162,6 +166,8 @@ github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
|||||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
|
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||||
|
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
|
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.459"
|
const GoextVersion = "0.0.462"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2024-05-20T00:20:31+0200"
|
const GoextVersionTimestamp = "2024-05-23T14:37:05+0200"
|
||||||
|
9
wpdf/utils.go
Normal file
9
wpdf/utils.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package wpdf
|
||||||
|
|
||||||
|
func hexToColor(c uint32) PDFColor {
|
||||||
|
return PDFColor{R: int((c >> 16) & 0xFF), G: int((c >> 8) & 0xFF), B: int((c >> 0) & 0xFF)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func rgbToColor(r, g, b int) PDFColor {
|
||||||
|
return PDFColor{R: r, G: g, B: b}
|
||||||
|
}
|
@@ -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()
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,10 @@ type PDFCellOpt struct {
|
|||||||
extraLn *float64
|
extraLn *float64
|
||||||
x *float64
|
x *float64
|
||||||
autoWidth *bool
|
autoWidth *bool
|
||||||
|
textColor *PDFColor
|
||||||
|
borderColor *PDFColor
|
||||||
|
fillColor *PDFColor
|
||||||
|
autoWidthPaddingX *float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPDFCellOpt() *PDFCellOpt {
|
func NewPDFCellOpt() *PDFCellOpt {
|
||||||
@@ -110,6 +114,41 @@ 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 {
|
||||||
|
opt.textColor = langext.Ptr(rgbToColor(cr, cg, cb))
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *PDFCellOpt) TextColorHex(c uint32) *PDFCellOpt {
|
||||||
|
opt.textColor = langext.Ptr(hexToColor(c))
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *PDFCellOpt) BorderColor(cr, cg, cb int) *PDFCellOpt {
|
||||||
|
opt.borderColor = langext.Ptr(rgbToColor(cr, cg, cb))
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *PDFCellOpt) BorderColorHex(c uint32) *PDFCellOpt {
|
||||||
|
opt.borderColor = langext.Ptr(hexToColor(c))
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *PDFCellOpt) FillColor(cr, cg, cb int) *PDFCellOpt {
|
||||||
|
opt.fillColor = langext.Ptr(rgbToColor(cr, cg, cb))
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *PDFCellOpt) FillColorHex(c uint32) *PDFCellOpt {
|
||||||
|
opt.fillColor = langext.Ptr(hexToColor(c))
|
||||||
|
return opt
|
||||||
|
}
|
||||||
|
|
||||||
func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
||||||
|
|
||||||
txtTR := b.tr(txt)
|
txtTR := b.tr(txt)
|
||||||
@@ -128,6 +167,10 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
|||||||
extraLn := float64(0)
|
extraLn := float64(0)
|
||||||
var x *float64
|
var x *float64
|
||||||
autoWidth := false
|
autoWidth := false
|
||||||
|
var textColor *PDFColor
|
||||||
|
var borderColor *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)
|
||||||
@@ -144,6 +187,10 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
|||||||
extraLn = langext.Coalesce(opt.extraLn, extraLn)
|
extraLn = langext.Coalesce(opt.extraLn, extraLn)
|
||||||
x = langext.CoalesceOpt(opt.x, x)
|
x = langext.CoalesceOpt(opt.x, x)
|
||||||
autoWidth = langext.Coalesce(opt.autoWidth, autoWidth)
|
autoWidth = langext.Coalesce(opt.autoWidth, autoWidth)
|
||||||
|
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 {
|
if fontNameOverride != nil || fontStyleOverride != nil || fontSizeOverride != nil {
|
||||||
@@ -157,12 +204,30 @@ func (b *WPDFBuilder) Cell(txt string, opts ...*PDFCellOpt) {
|
|||||||
defer func() { b.SetFont(oldFontName, oldFontStyle, oldFontSize) }()
|
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 {
|
if x != nil {
|
||||||
b.b.SetX(*x)
|
b.b.SetX(*x)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@@ -13,6 +13,9 @@ type PDFMultiCellOpt struct {
|
|||||||
fontSizeOverride *float64
|
fontSizeOverride *float64
|
||||||
extraLn *float64
|
extraLn *float64
|
||||||
x *float64
|
x *float64
|
||||||
|
textColor *PDFColor
|
||||||
|
borderColor *PDFColor
|
||||||
|
fillColor *PDFColor
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPDFMultiCellOpt() *PDFMultiCellOpt {
|
func NewPDFMultiCellOpt() *PDFMultiCellOpt {
|
||||||
@@ -86,6 +89,36 @@ func (opt *PDFMultiCellOpt) X(v float64) *PDFMultiCellOpt {
|
|||||||
return opt
|
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) {
|
func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
|
||||||
|
|
||||||
txtTR := b.tr(txt)
|
txtTR := b.tr(txt)
|
||||||
@@ -100,6 +133,9 @@ func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
|
|||||||
var fontSizeOverride *float64
|
var fontSizeOverride *float64
|
||||||
extraLn := float64(0)
|
extraLn := float64(0)
|
||||||
var x *float64
|
var x *float64
|
||||||
|
var textColor *PDFColor
|
||||||
|
var borderColor *PDFColor
|
||||||
|
var fillColor *PDFColor
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
width = langext.Coalesce(opt.width, width)
|
width = langext.Coalesce(opt.width, width)
|
||||||
@@ -112,6 +148,9 @@ func (b *WPDFBuilder) MultiCell(txt string, opts ...*PDFMultiCellOpt) {
|
|||||||
fontSizeOverride = langext.CoalesceOpt(opt.fontSizeOverride, fontSizeOverride)
|
fontSizeOverride = langext.CoalesceOpt(opt.fontSizeOverride, fontSizeOverride)
|
||||||
extraLn = langext.Coalesce(opt.extraLn, extraLn)
|
extraLn = langext.Coalesce(opt.extraLn, extraLn)
|
||||||
x = langext.CoalesceOpt(opt.x, x)
|
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 {
|
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) }()
|
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 {
|
if x != nil {
|
||||||
b.b.SetX(*x)
|
b.b.SetX(*x)
|
||||||
}
|
}
|
||||||
|
@@ -34,22 +34,22 @@ func (opt *PDFRectOpt) LineWidth(v float64) *PDFRectOpt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (opt *PDFRectOpt) DrawColor(cr, cg, cb int) *PDFRectOpt {
|
func (opt *PDFRectOpt) DrawColor(cr, cg, cb int) *PDFRectOpt {
|
||||||
opt.drawColor = &PDFColor{R: cr, G: cg, B: cb}
|
opt.drawColor = langext.Ptr(rgbToColor(cr, cg, cb))
|
||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opt *PDFRectOpt) DrawColorHex(c uint32) *PDFRectOpt {
|
func (opt *PDFRectOpt) DrawColorHex(c uint32) *PDFRectOpt {
|
||||||
opt.drawColor = &PDFColor{R: int((c >> 16) & 0xFF), G: int((c >> 8) & 0xFF), B: int((c >> 0) & 0xFF)}
|
opt.drawColor = langext.Ptr(hexToColor(c))
|
||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opt *PDFRectOpt) FillColor(cr, cg, cb int) *PDFRectOpt {
|
func (opt *PDFRectOpt) FillColor(cr, cg, cb int) *PDFRectOpt {
|
||||||
opt.fillColor = &PDFColor{R: cr, G: cg, B: cb}
|
opt.fillColor = langext.Ptr(rgbToColor(cr, cg, cb))
|
||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opt *PDFRectOpt) FillColorHex(c uint32) *PDFRectOpt {
|
func (opt *PDFRectOpt) FillColorHex(c uint32) *PDFRectOpt {
|
||||||
opt.fillColor = &PDFColor{R: int((c >> 16) & 0xFF), G: int((c >> 8) & 0xFF), B: int((c >> 0) & 0xFF)}
|
opt.fillColor = langext.Ptr(hexToColor(c))
|
||||||
return opt
|
return opt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user