summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@code.google.com>2014-02-13 16:10:53 -0500
committerKurt Jung <kurt.w.jung@code.google.com>2014-02-13 16:10:53 -0500
commit54926dff7aced06e420e30acacf942650e7a6e59 (patch)
treef3a88ba82cda42bfc6e962d05d78ff6ee69d79aa /fpdf_test.go
parent5c3d717c55e3a9cadd924d6b20eab99f8f9615ba (diff)
Patch provided by Stefan Schroeder to control vertical alignment of text within cell.
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index e771ac5..aaf5807 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -1086,3 +1086,40 @@ func ExampleFpdf_tutorial20() {
// Output:
// Successfully generated pdf/tutorial20.pdf
}
+
+// This example demonstrates Stefan Schroeder's code to control vertical
+// alignment.
+func ExampleFpdf_tutorial21() {
+ type recType struct {
+ align, txt string
+ }
+ recList := []recType{
+ recType{"TL", "top left"},
+ recType{"TC", "top center"},
+ recType{"TR", "top right"},
+ recType{"LM", "middle left"},
+ recType{"CM", "middle center"},
+ recType{"RM", "middle right"},
+ recType{"BL", "bottom left"},
+ recType{"BC", "bottom center"},
+ recType{"BR", "bottom right"},
+ }
+ pdf := gofpdf.New("P", "mm", "A4", cnFontDir) // A4 210.0 x 297.0
+ pdf.SetFont("Helvetica", "", 16)
+ linkStr := ""
+ for pageJ := 0; pageJ < 2; pageJ++ {
+ pdf.AddPage()
+ pdf.SetMargins(10, 10, 10)
+ pdf.SetAutoPageBreak(false, 0)
+ borderStr := "1"
+ for _, rec := range recList {
+ pdf.SetXY(20, 20)
+ pdf.CellFormat(170, 257, rec.txt, borderStr, 0, rec.align, false, 0, linkStr)
+ borderStr = ""
+ }
+ linkStr = "https://code.google.com/p/gofpdf/"
+ }
+ pdf.OutputAndClose(docWriter(pdf, 21))
+ // Output:
+ // Successfully generated pdf/tutorial21.pdf
+}