summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorStani <spe.stani.be@gmail.com>2015-07-12 17:03:33 +0200
committerStani <spe.stani.be@gmail.com>2015-07-12 17:05:13 +0200
commitf00c0a597be2dca589bdd7bd6ba5937b19ebdcfe (patch)
treea363671fb0fd63a61fe4ed084b576799a4c843d8 /fpdf_test.go
parent4aa4a931b57c01e39ef920dce28cf8210e2c4cb0 (diff)
implement vertical baseline alignment for text
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go42
1 files changed, 29 insertions, 13 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index fdc3334..63d4655 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -1175,25 +1175,41 @@ func ExampleFpdf_CellFormat_2() {
recType{"BC", "bottom center"},
recType{"BR", "bottom right"},
}
- pdf := gofpdf.New("P", "mm", "A4", "") // 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 = ""
+ recListBaseline := []recType{
+ recType{"AL", "baseline left"},
+ recType{"AC", "baseline center"},
+ recType{"AR", "baseline right"},
+ }
+ var formatRect = func(pdf *gofpdf.Fpdf, recList []recType) {
+ 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://github.com/jung-kurt/gofpdf"
}
- linkStr = "https://github.com/jung-kurt/gofpdf"
}
+ pdf := gofpdf.New("P", "mm", "A4", "") // A4 210.0 x 297.0
+ pdf.SetFont("Helvetica", "", 16)
+ formatRect(pdf, recList)
+ formatRect(pdf, recListBaseline)
+ var fr fontResourceType
+ pdf.SetFontLoader(fr)
+ pdf.AddFont("Calligrapher", "", "calligra.json")
+ pdf.SetFont("Calligrapher", "", 16)
+ formatRect(pdf, recListBaseline)
fileStr := exampleFilename("Fpdf_CellFormat_2_align")
err := pdf.OutputFileAndClose(fileStr)
summary(err, fileStr)
// Output:
+ // Generalized font loader reading calligra.json
+ // Generalized font loader reading calligra.z
// Successfully generated pdf/Fpdf_CellFormat_2_align.pdf
}