代码拉取完成,页面将自动刷新
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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。