v0.0.496 wpdf fixes and wpdf test.go
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 4m58s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 4m58s
This commit is contained in:
32
wpdf/wpdf.go
32
wpdf/wpdf.go
@@ -14,6 +14,7 @@ type WPDFBuilder struct {
|
||||
fontName PDFFontFamily
|
||||
fontStyle PDFFontStyle
|
||||
fontSize float64
|
||||
debug bool
|
||||
}
|
||||
|
||||
type PDFMargins struct {
|
||||
@@ -62,6 +63,19 @@ func (b *WPDFBuilder) SetMargins(v PDFMargins) {
|
||||
|
||||
func (b *WPDFBuilder) AddPage() {
|
||||
b.b.AddPage()
|
||||
|
||||
if b.debug {
|
||||
|
||||
ml, mt, mr, mb := b.GetMargins()
|
||||
pw, ph := b.GetPageSize()
|
||||
|
||||
b.Rect(pw-ml-mr, ph-mt-mb, RectOutline, NewPDFRectOpt().X(ml).Y(mt).LineWidth(0.25).DrawColor(0, 0, 128))
|
||||
|
||||
b.Rect(pw, mt, RectFill, NewPDFRectOpt().X(0).Y(0).FillColor(0, 0, 255).Alpha(0.2, BlendNormal))
|
||||
b.Rect(ml, ph-mt-mb, RectFill, NewPDFRectOpt().X(0).Y(mt).FillColor(0, 0, 255).Alpha(0.2, BlendNormal))
|
||||
b.Rect(mr, ph-mt-mb, RectFill, NewPDFRectOpt().X(pw-mr).Y(mt).FillColor(0, 0, 255).Alpha(0.2, BlendNormal))
|
||||
b.Rect(pw, mb, RectFill, NewPDFRectOpt().X(0).Y(ph-mb).FillColor(0, 0, 255).Alpha(0.2, BlendNormal))
|
||||
}
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) SetTextColor(cr, cg, cb int) {
|
||||
@@ -123,7 +137,21 @@ func (b *WPDFBuilder) SetCellSpacing(h float64) {
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) Ln(h float64) {
|
||||
xBefore, yBefore := b.GetXY()
|
||||
|
||||
b.b.Ln(h)
|
||||
|
||||
yAfter := b.GetY()
|
||||
|
||||
if b.debug {
|
||||
|
||||
_, _, mr, _ := b.GetMargins()
|
||||
pw, _ := b.GetPageSize()
|
||||
|
||||
b.Rect(pw-mr-xBefore, yAfter-yBefore, RectOutline, NewPDFRectOpt().X(xBefore).Y(yBefore).LineWidth(0.25).DrawColor(128, 128, 0).Alpha(0.5, BlendNormal))
|
||||
b.Rect(pw-mr-xBefore, yAfter-yBefore, RectFill, NewPDFRectOpt().X(xBefore).Y(yBefore).LineWidth(0.25).FillColor(128, 128, 0).Alpha(0.1, BlendNormal))
|
||||
b.Line(xBefore, yBefore, pw-mr, yAfter, NewPDFLineOpt().LineWidth(0.25).DrawColor(128, 128, 0))
|
||||
}
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) Build() ([]byte, error) {
|
||||
@@ -242,3 +270,7 @@ func (b *WPDFBuilder) GetStringWidth(str string, opts ...PDFCellOpt) float64 {
|
||||
|
||||
return b.b.GetStringWidth(str)
|
||||
}
|
||||
|
||||
func (b *WPDFBuilder) Debug(v bool) {
|
||||
b.debug = v
|
||||
}
|
||||
|
Reference in New Issue
Block a user