diff options
author | Kevin Seidel <kevin@zahlz.com> | 2018-01-02 14:38:12 +0100 |
---|---|---|
committer | Kevin Seidel <kevin@zahlz.com> | 2018-01-02 14:38:12 +0100 |
commit | 242444464510f0bf64b60f38f6f44e28d3da137f (patch) | |
tree | ca6b27bdecbebe8a54cc3276f791ff2c95aa2da9 /fpdf.go | |
parent | d0cda52642506c515aed23ac7468831de11ad465 (diff) | |
parent | c8debdafb5eeac8330420d4b1699cc1094237805 (diff) |
Merge branch 'master' of https://github.com/jung-kurt/gofpdf
Diffstat (limited to 'fpdf.go')
-rw-r--r-- | fpdf.go | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -59,7 +59,9 @@ func (b *fmtBuffer) printf(fmtStr string, args ...interface{}) { func fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr string, size SizeType) (f *Fpdf) { f = new(Fpdf) if orientationStr == "" { - orientationStr = "P" + orientationStr = "p" + } else { + orientationStr = strings.ToLower(orientationStr) } if unitStr == "" { unitStr = "mm" @@ -143,7 +145,6 @@ func fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr string, size SizeType) } f.curPageSize = f.defPageSize // Page orientation - orientationStr = strings.ToLower(orientationStr) switch orientationStr { case "p", "portrait": f.defOrientation = "P" @@ -1931,19 +1932,19 @@ func (f *Fpdf) CellFormat(w, h float64, txtStr string, borderStr string, ln int, if len(txtStr) > 0 { var dx, dy float64 // Horizontal alignment - if strings.Index(alignStr, "R") != -1 { + if strings.Contains(alignStr, "R") { dx = w - f.cMargin - f.GetStringWidth(txtStr) - } else if strings.Index(alignStr, "C") != -1 { + } else if strings.Contains(alignStr, "C") { dx = (w - f.GetStringWidth(txtStr)) / 2 } else { dx = f.cMargin } // Vertical alignment - if strings.Index(alignStr, "T") != -1 { + if strings.Contains(alignStr, "T") { dy = (f.fontSize - h) / 2.0 - } else if strings.Index(alignStr, "B") != -1 { + } else if strings.Contains(alignStr, "B") { dy = (h - f.fontSize) / 2.0 - } else if strings.Index(alignStr, "A") != -1 { + } else if strings.Contains(alignStr, "A") { var descent float64 d := f.currentFont.Desc if d.Descent == 0 { |