summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
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
}