mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-01 22:17:29 +08:00
Merge branch 'master' of https://github.com/s4kibs4mi/unidoc into s4kibs4mi-master and address border centering for double border
This commit is contained in:
commit
296596e4c9
@ -134,16 +134,44 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if border.borderWidthTop != 0 {
|
// a is the spacing between inner and outer line centers (double border only).
|
||||||
if border.StyleTop == CellBorderStyleDoubleTop {
|
aTop := border.borderWidthTop
|
||||||
x := startX
|
aBottom := border.borderWidthBottom
|
||||||
y := startY
|
aLeft := border.borderWidthLeft
|
||||||
|
aRight := border.borderWidthRight
|
||||||
|
|
||||||
|
// wb represents the effective width of border (including gap and double lines in double border).
|
||||||
|
wbTop := border.borderWidthTop
|
||||||
|
if border.StyleTop == CellBorderStyleDoubleTop {
|
||||||
|
wbTop += 2 * aTop
|
||||||
|
}
|
||||||
|
wbBottom := border.borderWidthBottom
|
||||||
|
if border.StyleBottom == CellBorderStyleDoubleBottom {
|
||||||
|
wbBottom += 2 * aBottom
|
||||||
|
}
|
||||||
|
wbLeft := border.borderWidthLeft
|
||||||
|
if border.StyleLeft == CellBorderStyleDoubleLeft {
|
||||||
|
wbLeft += 2 * aLeft
|
||||||
|
}
|
||||||
|
wbRight := border.borderWidthRight
|
||||||
|
if border.StyleRight == CellBorderStyleDoubleRight {
|
||||||
|
wbRight += 2 * aRight
|
||||||
|
}
|
||||||
|
|
||||||
|
// Left border.
|
||||||
|
if border.borderWidthTop != 0 {
|
||||||
|
x := startX
|
||||||
|
y := startY
|
||||||
|
|
||||||
|
if border.StyleTop == CellBorderStyleDoubleTop {
|
||||||
|
y -= aTop
|
||||||
|
|
||||||
|
// Double - Outer line.
|
||||||
lineTop := draw.BasicLine{}
|
lineTop := draw.BasicLine{}
|
||||||
lineTop.X1 = x
|
lineTop.X1 = x - wbTop/2
|
||||||
lineTop.Y1 = y
|
lineTop.Y1 = y + 2*aTop
|
||||||
lineTop.X2 = x + border.width
|
lineTop.X2 = x + border.width + wbTop/2
|
||||||
lineTop.Y2 = y
|
lineTop.Y2 = y + 2*aTop
|
||||||
lineTop.LineColor = border.borderColorTop
|
lineTop.LineColor = border.borderColorTop
|
||||||
lineTop.LineWidth = border.borderWidthTop
|
lineTop.LineWidth = border.borderWidthTop
|
||||||
lineTop.LineStyle = border.LineStyle
|
lineTop.LineStyle = border.LineStyle
|
||||||
@ -157,15 +185,14 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line Top
|
|
||||||
lineTop := draw.BasicLine{
|
lineTop := draw.BasicLine{
|
||||||
LineWidth: border.borderWidthTop,
|
LineWidth: border.borderWidthTop,
|
||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorTop,
|
LineColor: border.borderColorTop,
|
||||||
X1: startX - border.borderWidthTop/2,
|
X1: x - wbTop/2 + (wbLeft - border.borderWidthLeft),
|
||||||
Y1: startY,
|
Y1: y,
|
||||||
X2: startX + border.width + border.borderWidthTop/2,
|
X2: x + border.width + wbTop/2 - (wbRight - border.borderWidthRight),
|
||||||
Y2: startY,
|
Y2: y,
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
contentsTop, _, err := lineTop.Draw("")
|
contentsTop, _, err := lineTop.Draw("")
|
||||||
@ -178,22 +205,22 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bottom border.
|
||||||
if border.borderWidthBottom != 0 {
|
if border.borderWidthBottom != 0 {
|
||||||
x := startX
|
x := startX
|
||||||
y := startY - border.height
|
y := startY - border.height
|
||||||
|
|
||||||
if border.StyleBottom == CellBorderStyleDoubleBottom {
|
if border.StyleBottom == CellBorderStyleDoubleBottom {
|
||||||
dx := x
|
y += aBottom
|
||||||
dy := y
|
// Double border - Outer line.
|
||||||
|
|
||||||
lineBottom := draw.BasicLine{
|
lineBottom := draw.BasicLine{
|
||||||
LineWidth: border.borderWidthBottom,
|
LineWidth: border.borderWidthBottom,
|
||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorBottom,
|
LineColor: border.borderColorBottom,
|
||||||
X1: dx,
|
X1: x - wbBottom/2,
|
||||||
Y1: dy,
|
Y1: y - 2*aBottom,
|
||||||
X2: dx,
|
X2: x + border.width + wbBottom/2,
|
||||||
Y2: dy,
|
Y2: y - 2*aBottom,
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
contentsBottom, _, err := lineBottom.Draw("")
|
contentsBottom, _, err := lineBottom.Draw("")
|
||||||
@ -210,9 +237,9 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
LineWidth: border.borderWidthBottom,
|
LineWidth: border.borderWidthBottom,
|
||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorBottom,
|
LineColor: border.borderColorBottom,
|
||||||
X1: x - border.borderWidthBottom/2,
|
X1: x - wbBottom/2 + (wbLeft - border.borderWidthLeft),
|
||||||
Y1: y,
|
Y1: y,
|
||||||
X2: x + border.width + border.borderWidthBottom/2,
|
X2: x + border.width + wbBottom/2 - (wbRight - border.borderWidthRight),
|
||||||
Y2: y,
|
Y2: y,
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
@ -226,20 +253,23 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Left border.
|
||||||
if border.borderWidthLeft != 0 {
|
if border.borderWidthLeft != 0 {
|
||||||
x := startX
|
x := startX
|
||||||
y := startY
|
y := startY
|
||||||
|
|
||||||
if border.StyleLeft == CellBorderStyleDoubleLeft {
|
if border.StyleLeft == CellBorderStyleDoubleLeft {
|
||||||
// Line Left
|
x += aLeft
|
||||||
|
|
||||||
|
// Double border - outer line.
|
||||||
lineLeft := draw.BasicLine{
|
lineLeft := draw.BasicLine{
|
||||||
LineWidth: border.borderWidthLeft,
|
LineWidth: border.borderWidthLeft,
|
||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorLeft,
|
LineColor: border.borderColorLeft,
|
||||||
X1: x,
|
X1: x - 2*aLeft,
|
||||||
Y1: y,
|
Y1: y + wbLeft/2,
|
||||||
X2: x,
|
X2: x - 2*aLeft,
|
||||||
Y2: y - border.height,
|
Y2: y - border.height - wbLeft/2,
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
contentsLeft, _, err := lineLeft.Draw("")
|
contentsLeft, _, err := lineLeft.Draw("")
|
||||||
@ -258,9 +288,9 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorLeft,
|
LineColor: border.borderColorLeft,
|
||||||
X1: x,
|
X1: x,
|
||||||
Y1: y + border.borderWidthLeft/2,
|
Y1: y + wbLeft/2 - (wbTop - border.borderWidthTop),
|
||||||
X2: x,
|
X2: x,
|
||||||
Y2: y - border.height - border.borderWidthLeft/2,
|
Y2: y - border.height - wbLeft/2 + (wbBottom - border.borderWidthBottom),
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
contentsLeft, _, err := lineLeft.Draw("")
|
contentsLeft, _, err := lineLeft.Draw("")
|
||||||
@ -273,20 +303,23 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Right border.
|
||||||
if border.borderWidthRight != 0 {
|
if border.borderWidthRight != 0 {
|
||||||
x := startX + border.width
|
x := startX + border.width
|
||||||
y := startY
|
y := startY
|
||||||
|
|
||||||
if border.StyleRight == CellBorderStyleDoubleRight {
|
if border.StyleRight == CellBorderStyleDoubleRight {
|
||||||
// Line Right
|
x -= aRight
|
||||||
|
|
||||||
|
// Double border - Outer line.
|
||||||
lineRight := draw.BasicLine{
|
lineRight := draw.BasicLine{
|
||||||
LineWidth: border.borderWidthRight,
|
LineWidth: border.borderWidthRight,
|
||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorRight,
|
LineColor: border.borderColorRight,
|
||||||
X1: x,
|
X1: x + 2*aRight,
|
||||||
Y1: y,
|
Y1: y + wbRight/2,
|
||||||
X2: x,
|
X2: x + 2*aRight,
|
||||||
Y2: y - border.height,
|
Y2: y - border.height - wbRight/2,
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
contentsRight, _, err := lineRight.Draw("")
|
contentsRight, _, err := lineRight.Draw("")
|
||||||
@ -299,15 +332,14 @@ func (border *border) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line Right
|
|
||||||
lineRight := draw.BasicLine{
|
lineRight := draw.BasicLine{
|
||||||
LineWidth: border.borderWidthRight,
|
LineWidth: border.borderWidthRight,
|
||||||
Opacity: 1.0,
|
Opacity: 1.0,
|
||||||
LineColor: border.borderColorRight,
|
LineColor: border.borderColorRight,
|
||||||
X1: x,
|
X1: x,
|
||||||
Y1: y + border.borderWidthRight/2,
|
Y1: y + wbRight/2 - (wbTop - border.borderWidthTop),
|
||||||
X2: x,
|
X2: x,
|
||||||
Y2: y - border.height - border.borderWidthRight/2,
|
Y2: y - border.height - wbRight/2 + (wbBottom - border.borderWidthBottom),
|
||||||
LineStyle: border.LineStyle,
|
LineStyle: border.LineStyle,
|
||||||
}
|
}
|
||||||
contentsRight, _, err := lineRight.Draw("")
|
contentsRight, _, err := lineRight.Draw("")
|
||||||
|
@ -1429,71 +1429,71 @@ func TestCreatorTableBorderReq1(t *testing.T) {
|
|||||||
add := table6.NewCell()
|
add := table6.NewCell()
|
||||||
add.SetContent(newContent("A", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
add.SetContent(newContent("A", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
add.SetBorder(CellBorderStyleDoubleTop, 1)
|
add.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
add.SetBorder(CellBorderStyleRight, 1)
|
add.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
add.SetBorder(CellBorderStyleDoubleLeft, 1)
|
add.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
add.SetBorder(CellBorderStyleBottom, 1)
|
add.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
bdd := table6.NewCell()
|
bdd := table6.NewCell()
|
||||||
bdd.SetContent(newContent("B", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
bdd.SetContent(newContent("B", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
bdd.SetBorder(CellBorderStyleDoubleBox, 1)
|
bdd.SetBorder(CellBorderStyleDoubleBox, 1)
|
||||||
bdd.SetBorder(CellBorderStyleRight, 1)
|
bdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
bdd.SetBorder(CellBorderStyleLeft, 1)
|
bdd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
bdd.SetBorder(CellBorderStyleBottom, 1)
|
bdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
ccdd := table6.NewCell()
|
ccdd := table6.NewCell()
|
||||||
ccdd.SetContent(newContent("C", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
ccdd.SetContent(newContent("C", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
ccdd.SetBorder(CellBorderStyleDoubleTop, 1)
|
ccdd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
ccdd.SetBorder(CellBorderStyleRight, 1)
|
ccdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
ccdd.SetBorder(CellBorderStyleLeft, 1)
|
ccdd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
ccdd.SetBorder(CellBorderStyleBottom, 1)
|
ccdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
ddd := table6.NewCell()
|
ddd := table6.NewCell()
|
||||||
ddd.SetContent(newContent("D", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
ddd.SetContent(newContent("D", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
ddd.SetBorder(CellBorderStyleDoubleTop, 1)
|
ddd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
ddd.SetBorder(CellBorderStyleDoubleRight, 1)
|
ddd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
ddd.SetBorder(CellBorderStyleLeft, 1)
|
ddd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
ddd.SetBorder(CellBorderStyleBottom, 1)
|
ddd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
edd := table6.NewCell()
|
edd := table6.NewCell()
|
||||||
edd.SetContent(newContent("E", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
edd.SetContent(newContent("E", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
edd.SetBorder(CellBorderStyleTop, 1)
|
edd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
edd.SetBorder(CellBorderStyleRight, 1)
|
edd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
edd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
edd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
edd.SetBorder(CellBorderStyleBottom, 1)
|
edd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
fdd := table6.NewCell()
|
fdd := table6.NewCell()
|
||||||
fdd.SetContent(newContent("F", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
fdd.SetContent(newContent("F", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
fdd.SetBorder(CellBorderStyleTop, 1)
|
fdd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
fdd.SetBorder(CellBorderStyleRight, 1)
|
fdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
fdd.SetBorder(CellBorderStyleLeft, 1)
|
fdd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
fdd.SetBorder(CellBorderStyleBottom, 1)
|
fdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
gdd := table6.NewCell()
|
gdd := table6.NewCell()
|
||||||
gdd.SetContent(newContent("G", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
gdd.SetContent(newContent("G", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
gdd.SetBorder(CellBorderStyleTop, 1)
|
gdd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
gdd.SetBorder(CellBorderStyleRight, 1)
|
gdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
gdd.SetBorder(CellBorderStyleLeft, 1)
|
gdd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
gdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
gdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
hdd := table6.NewCell()
|
hdd := table6.NewCell()
|
||||||
hdd.SetContent(newContent("H", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
hdd.SetContent(newContent("H", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
hdd.SetBorder(CellBorderStyleTop, 1)
|
hdd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
hdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
hdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
hdd.SetBorder(CellBorderStyleLeft, 1)
|
hdd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
hdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
hdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
idd := table6.NewCell()
|
idd := table6.NewCell()
|
||||||
idd.SetContent(newContent("I", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
idd.SetContent(newContent("I", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
idd.SetBorder(CellBorderStyleTop, 1)
|
idd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
idd.SetBorder(CellBorderStyleRight, 1)
|
idd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
idd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
idd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
idd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
idd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
jdd := table6.NewCell()
|
jdd := table6.NewCell()
|
||||||
jdd.SetContent(newContent("J", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
jdd.SetContent(newContent("J", TextAlignmentLeft, fonts.NewFontTimesRoman(), 10, ColorBlack))
|
||||||
jdd.SetBorder(CellBorderStyleTop, 1)
|
jdd.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
jdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
jdd.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
jdd.SetBorder(CellBorderStyleLeft, 1)
|
jdd.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
jdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
jdd.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
|
||||||
table7 := NewTable(1) // Mx4 table
|
table7 := NewTable(1) // Mx4 table
|
||||||
@ -1627,8 +1627,7 @@ func TestCreatorTableBorderReq1(t *testing.T) {
|
|||||||
c.Draw(table9)
|
c.Draw(table9)
|
||||||
c.Draw(table10)
|
c.Draw(table10)
|
||||||
|
|
||||||
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
||||||
err := c.WriteToFile("../../testfiles/table.pdf")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Fail: %v\n", err)
|
t.Errorf("Fail: %v\n", err)
|
||||||
return
|
return
|
||||||
@ -1643,8 +1642,7 @@ func TestBasicLine(t *testing.T) {
|
|||||||
c := New()
|
c := New()
|
||||||
c.Draw(line)
|
c.Draw(line)
|
||||||
|
|
||||||
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
err := c.WriteToFile("/tmp/basic_line.pdf")
|
||||||
err := c.WriteToFile("../../testfiles/table.pdf")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Fail: %v\n", err)
|
t.Errorf("Fail: %v\n", err)
|
||||||
return
|
return
|
||||||
@ -1660,8 +1658,7 @@ func TestBasicLineWithDash(t *testing.T) {
|
|||||||
c := New()
|
c := New()
|
||||||
c.Draw(line)
|
c.Draw(line)
|
||||||
|
|
||||||
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
err := c.WriteToFile("/tmp/basic_line_with_dash.pdf")
|
||||||
err := c.WriteToFile("../../testfiles/table.pdf")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Fail: %v\n", err)
|
t.Errorf("Fail: %v\n", err)
|
||||||
return
|
return
|
||||||
@ -1688,8 +1685,7 @@ func TestRectangle(t *testing.T) {
|
|||||||
c.Draw(top)
|
c.Draw(top)
|
||||||
c.Draw(right)
|
c.Draw(right)
|
||||||
|
|
||||||
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
err := c.WriteToFile("/tmp/rectangle.pdf")
|
||||||
err := c.WriteToFile("../../testfiles/table.pdf")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Fail: %v\n", err)
|
t.Errorf("Fail: %v\n", err)
|
||||||
return
|
return
|
||||||
@ -1704,10 +1700,15 @@ func TestSingleBorder(t *testing.T) {
|
|||||||
border.SetColorLeft(ColorRed)
|
border.SetColorLeft(ColorRed)
|
||||||
border.SetColorRight(ColorRed)
|
border.SetColorRight(ColorRed)
|
||||||
|
|
||||||
border.SetWidthBottom(1)
|
border.SetWidthBottom(3)
|
||||||
border.SetWidthTop(1)
|
border.SetWidthTop(3)
|
||||||
border.SetWidthLeft(1)
|
border.SetWidthLeft(3)
|
||||||
border.SetWidthRight(1)
|
border.SetWidthRight(3)
|
||||||
|
|
||||||
|
border.StyleTop = CellBorderStyleDoubleTop
|
||||||
|
border.StyleBottom = CellBorderStyleDoubleBottom
|
||||||
|
border.StyleLeft = CellBorderStyleDoubleLeft
|
||||||
|
border.StyleRight = CellBorderStyleDoubleRight
|
||||||
|
|
||||||
c := New()
|
c := New()
|
||||||
c.Draw(border)
|
c.Draw(border)
|
||||||
@ -1721,19 +1722,111 @@ func TestSingleBorder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSingleBorder2(t *testing.T) {
|
||||||
|
border := newBorder(100, 100, 100, 100)
|
||||||
|
//border.SetFillColor(ColorRed)
|
||||||
|
border.SetColorBottom(ColorGreen)
|
||||||
|
border.SetColorTop(ColorGreen)
|
||||||
|
//border.SetColorLeft(ColorRed)
|
||||||
|
//border.SetColorRight(ColorRed)
|
||||||
|
|
||||||
|
border.SetWidthBottom(3)
|
||||||
|
border.SetWidthTop(3)
|
||||||
|
//border.SetWidthLeft(3)
|
||||||
|
//border.SetWidthRight(3)
|
||||||
|
|
||||||
|
border.StyleTop = CellBorderStyleDoubleTop
|
||||||
|
border.StyleBottom = CellBorderStyleDoubleBottom
|
||||||
|
//border.StyleLeft = CellBorderStyleDoubleLeft
|
||||||
|
//border.StyleRight = CellBorderStyleDoubleRight
|
||||||
|
|
||||||
|
c := New()
|
||||||
|
c.Draw(border)
|
||||||
|
|
||||||
|
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
||||||
|
//err := c.WriteToFile("../../testfiles/table.pdf")
|
||||||
|
err := c.WriteToFile("/tmp/border_single2.pdf")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Fail: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSingleBorder3(t *testing.T) {
|
||||||
|
border := newBorder(100, 100, 100, 100)
|
||||||
|
//border.SetFillColor(ColorRed)
|
||||||
|
//border.SetColorBottom(ColorGreen)
|
||||||
|
//border.SetColorTop(ColorGreen)
|
||||||
|
border.SetColorLeft(ColorRed)
|
||||||
|
border.SetColorRight(ColorRed)
|
||||||
|
|
||||||
|
//border.SetWidthBottom(3)
|
||||||
|
//border.SetWidthTop(3)
|
||||||
|
border.SetWidthLeft(3)
|
||||||
|
border.SetWidthRight(3)
|
||||||
|
|
||||||
|
//border.StyleTop = CellBorderStyleDoubleTop
|
||||||
|
//border.StyleBottom = CellBorderStyleDoubleBottom
|
||||||
|
border.StyleLeft = CellBorderStyleDoubleLeft
|
||||||
|
border.StyleRight = CellBorderStyleDoubleRight
|
||||||
|
|
||||||
|
c := New()
|
||||||
|
c.Draw(border)
|
||||||
|
|
||||||
|
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
||||||
|
//err := c.WriteToFile("../../testfiles/table.pdf")
|
||||||
|
err := c.WriteToFile("/tmp/border_single3.pdf")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Fail: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSingleBorder4(t *testing.T) {
|
||||||
|
border := newBorder(100, 100, 100, 100)
|
||||||
|
//border.SetFillColor(ColorRed)
|
||||||
|
border.SetColorBottom(ColorGreen)
|
||||||
|
border.SetColorTop(ColorGreen)
|
||||||
|
border.SetColorLeft(ColorRed)
|
||||||
|
border.SetColorRight(ColorRed)
|
||||||
|
|
||||||
|
border.SetWidthBottom(3)
|
||||||
|
border.SetWidthTop(3)
|
||||||
|
border.SetWidthLeft(3)
|
||||||
|
border.SetWidthRight(3)
|
||||||
|
|
||||||
|
border.StyleTop = CellBorderStyleTop
|
||||||
|
border.StyleBottom = CellBorderStyleDoubleBottom
|
||||||
|
border.StyleLeft = CellBorderStyleLeft
|
||||||
|
border.StyleRight = CellBorderStyleDoubleRight
|
||||||
|
|
||||||
|
c := New()
|
||||||
|
c.Draw(border)
|
||||||
|
|
||||||
|
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
||||||
|
//err := c.WriteToFile("../../testfiles/table.pdf")
|
||||||
|
err := c.WriteToFile("/tmp/border_single4.pdf")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Fail: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCellBorder(t *testing.T) {
|
func TestCellBorder(t *testing.T) {
|
||||||
table := NewTable(2)
|
table := NewTable(2)
|
||||||
table.SetColumnWidths(0.50, 0.50)
|
table.SetColumnWidths(0.50, 0.50)
|
||||||
|
|
||||||
cell1 := table.NewCell()
|
cell1 := table.NewCell()
|
||||||
cell1.SetContent(newContent("Cell 1", TextAlignmentLeft, fonts.NewFontTimesBold(), 8, ColorRed))
|
cell1.SetContent(newContent("Cell 1", TextAlignmentLeft, fonts.NewFontTimesBold(), 8, ColorRed))
|
||||||
cell1.SetBorder(CellBorderStyleBox, 3)
|
cell1.SetBorder(CellBorderStyleDoubleTop, 1)
|
||||||
|
cell1.SetBorder(CellBorderStyleDoubleBottom, 1)
|
||||||
|
cell1.SetBorder(CellBorderStyleDoubleLeft, 1)
|
||||||
|
cell1.SetBorder(CellBorderStyleDoubleRight, 1)
|
||||||
|
|
||||||
c := New()
|
c := New()
|
||||||
c.Draw(table)
|
c.Draw(table)
|
||||||
|
|
||||||
//err := c.WriteToFile("/tmp/table_border_req1_test.pdf")
|
err := c.WriteToFile("/tmp/cell.pdf")
|
||||||
err := c.WriteToFile("../../testfiles/table.pdf")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Fail: %v\n", err)
|
t.Errorf("Fail: %v\n", err)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user