summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--def.go5
-rw-r--r--fpdf.go5
-rw-r--r--fpdf_test.go2
3 files changed, 9 insertions, 3 deletions
diff --git a/def.go b/def.go
index 88e4dea..52e6474 100644
--- a/def.go
+++ b/def.go
@@ -39,6 +39,11 @@ type gradientType struct {
objNum int
}
+const (
+ OrientationPortrait = "portrait"
+ OrientationLandscape = "landscape"
+)
+
type colorMode int
const (
diff --git a/fpdf.go b/fpdf.go
index 1503a4e..567311d 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -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"
diff --git a/fpdf_test.go b/fpdf_test.go
index 76ef558..ff41fd2 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -191,7 +191,7 @@ func lorem() string {
// finally retrieved with the output call where it can be handled by the
// application.
func Example() {
- pdf := gofpdf.New("P", "mm", "A4", "")
+ pdf := gofpdf.New(gofpdf.OrientationPortrait, "mm", "A4", "")
pdf.AddPage()
pdf.SetFont("Arial", "B", 16)
pdf.Cell(40, 10, "Hello World!")