1 Star 0 Fork 0

ckbabby / gopdf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
hr.go 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
ckbabby 提交于 2020-09-09 15:39 . 9-09
package gopdf
import (
"gitee.com/ckbabby/gopdf/core"
)
type HLine struct {
pdf *core.Report
color float64
width float64
margin core.Scope
}
func NewHLine(pdf *core.Report) *HLine {
return &HLine{
pdf: pdf,
color: 0,
width: 0.1,
margin: core.Scope{
Left: 0,
Right: 0,
Top: 0.3,
Bottom: 0.3,
},
}
}
func (h *HLine) SetColor(color float64) *HLine {
if color < 0 || color > 1.0 {
color = 0
}
h.color = color
return h
}
func (h *HLine) SetMargin(margin core.Scope) *HLine {
h.margin = margin
return h
}
func (h *HLine) SetWidth(width float64) *HLine {
h.width = width
return h
}
func (h *HLine) GenerateAtomicCell() {
var (
sx, sy = h.pdf.GetXY()
)
x := sx + h.margin.Left
y := sy + h.margin.Top
_, endY := h.pdf.GetPageEndXY()
if (sy >= endY || sy < endY) && sy+h.width > endY {
h.pdf.AddNewPage(false)
h.pdf.SetXY(h.pdf.GetPageStartXY())
h.GenerateAtomicCell()
return
}
cw, _ := h.pdf.GetContentWidthAndHeight()
h.pdf.LineGrayColor(x, y, cw, h.width, h.color)
x, _ = h.pdf.GetPageStartXY()
h.pdf.SetXY(x, y+h.margin.Bottom+h.width)
}
1
https://gitee.com/ckbabby/gopdf.git
git@gitee.com:ckbabby/gopdf.git
ckbabby
gopdf
gopdf
f60ce48249f4

搜索帮助