MultiCellWithOption vs CellWithOption behavior is different
YXH-YXH opened this issue · comments
CellWithOption and MultiCellWithOption behavior is different, when you continuous use them.
the function "CellWithOption" makes "AAAA",which is 1*n
,
but the function "MultiCellWithOption" makes "A\nA\nA\nA",which is n*1
.
In my opinion, the two function should be similar
my code like this (reproduce the bug)
opt := gopdf.CellOption{
Align: gopdf.Center | gopdf.Middle,
Border: gopdf.AllBorders,
Float: gopdf.Right,
}
rect := &gopdf.Rect{
W: fontSize * 3,
H: fontSize,
}
text:=abc
x := pdf.GetX()
y := pdf.GetY()
for i := 0; i < 5; i++ {
err = pdf.CellWithOption(rect, text, opt) // answer A
if err != nil {
log.Println(err)
}
}
pdf.SetXY(x, y+fontSize)
text = "123"
for i := 0; i < 5; i++ {
err = pdf.MultiCellWithOption(rect, text, opt) // answer B
if err != nil {
log.Println(err)
}
}
for answer A, the output likes
abcabcabcabcabc
for answer B, the output likes
123
123
123
123
123
I think both answer A and answer B are same,
I mean the answer A and answer B look like:
abcabcabcabcabc
123123123123123
How to fix it?
In the file ./gopdf.go
, find function "MultiCellWithOption", at about line 1145,
add the code
gp.SetX(x + rectangle.W)
gp.SetY(gp.GetY() - rectangle.H + 1)
befor the return nil
Ok
Ok
Ok
@oneplus1000 can you close this issue if it has been resolved? This seems like it's not actually a bug but rather a misunderstanding.