summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2018-11-21 07:11:04 -0500
committerKurt <kurt.w.jung@gmail.com>2018-11-21 07:11:04 -0500
commit17f0a23a8534e47957dba0091fba52b73af4061e (patch)
tree9be64e3c2eee1b3e260d0987a036bd901e47d6fe
parent2969a68dc5e762d0d5b8aac519058a9f73320316 (diff)
Center tables in example
-rw-r--r--fpdf_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 89c90b6..b3732e0 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -558,11 +558,14 @@ func ExampleFpdf_CellFormat_tables() {
}
// Simple table
basicTable := func() {
+ left := (210.0 - 4*40) / 2
+ pdf.SetX(left)
for _, str := range header {
pdf.CellFormat(40, 7, str, "1", 0, "", false, 0, "")
}
pdf.Ln(-1)
for _, c := range countryList {
+ pdf.SetX(left)
pdf.CellFormat(40, 6, c.nameStr, "1", 0, "", false, 0, "")
pdf.CellFormat(40, 6, c.capitalStr, "1", 0, "", false, 0, "")
pdf.CellFormat(40, 6, c.areaStr, "1", 0, "", false, 0, "")
@@ -578,13 +581,16 @@ func ExampleFpdf_CellFormat_tables() {
for _, v := range w {
wSum += v
}
+ left := (210 - wSum) / 2
// Header
+ pdf.SetX(left)
for j, str := range header {
pdf.CellFormat(w[j], 7, str, "1", 0, "C", false, 0, "")
}
pdf.Ln(-1)
// Data
for _, c := range countryList {
+ pdf.SetX(left)
pdf.CellFormat(w[0], 6, c.nameStr, "LR", 0, "", false, 0, "")
pdf.CellFormat(w[1], 6, c.capitalStr, "LR", 0, "", false, 0, "")
pdf.CellFormat(w[2], 6, strDelimit(c.areaStr, ",", 3),
@@ -593,6 +599,7 @@ func ExampleFpdf_CellFormat_tables() {
"LR", 0, "R", false, 0, "")
pdf.Ln(-1)
}
+ pdf.SetX(left)
pdf.CellFormat(wSum, 0, "", "T", 0, "", false, 0, "")
}
// Colored table
@@ -609,6 +616,8 @@ func ExampleFpdf_CellFormat_tables() {
for _, v := range w {
wSum += v
}
+ left := (210 - wSum) / 2
+ pdf.SetX(left)
for j, str := range header {
pdf.CellFormat(w[j], 7, str, "1", 0, "C", true, 0, "")
}
@@ -620,6 +629,7 @@ func ExampleFpdf_CellFormat_tables() {
// Data
fill := false
for _, c := range countryList {
+ pdf.SetX(left)
pdf.CellFormat(w[0], 6, c.nameStr, "LR", 0, "", fill, 0, "")
pdf.CellFormat(w[1], 6, c.capitalStr, "LR", 0, "", fill, 0, "")
pdf.CellFormat(w[2], 6, strDelimit(c.areaStr, ",", 3),
@@ -629,6 +639,7 @@ func ExampleFpdf_CellFormat_tables() {
pdf.Ln(-1)
fill = !fill
}
+ pdf.SetX(left)
pdf.CellFormat(wSum, 0, "", "T", 0, "", false, 0, "")
}
loadData(example.TextFile("countries.txt"))