summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdf_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 8f1f700..61dc6f9 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -596,11 +596,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, "")
@@ -616,13 +619,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),
@@ -631,6 +637,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
@@ -647,6 +654,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, "")
}
@@ -658,6 +667,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),
@@ -667,6 +677,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"))