summaryrefslogtreecommitdiff
path: root/template.go
diff options
context:
space:
mode:
authord1ngd0 <paul.david.montag@gmail.com>2018-11-01 10:31:48 -0500
committerKurt Jung <kurt.w.jung@gmail.com>2018-11-01 11:31:48 -0400
commit1e278c483c1f927b37a1ffd8e4d98b2c0b22a3d3 (patch)
treeb92b1f08fe905bfd66b4bb2400924561b6e7d5db /template.go
parentff1cd8e5b8ca41d73b5f75b21ee698cd1ef14241 (diff)
orientation of a template is now defined by the parent document. depricated CreateTemplate (#207)
Diffstat (limited to 'template.go')
-rw-r--r--template.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/template.go b/template.go
index 60b076b..0c86762 100644
--- a/template.go
+++ b/template.go
@@ -23,17 +23,27 @@ import (
// CreateTemplate defines a new template using the current page size.
func (f *Fpdf) CreateTemplate(fn func(*Tpl)) Template {
- return newTpl(PointType{0, 0}, f.curPageSize, f.unitStr, f.fontDirStr, fn, f)
+ return newTpl(PointType{0, 0}, f.curPageSize, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
}
// CreateTemplateCustom starts a template, using the given bounds.
func (f *Fpdf) CreateTemplateCustom(corner PointType, size SizeType, fn func(*Tpl)) Template {
- return newTpl(corner, size, f.unitStr, f.fontDirStr, fn, f)
+ return newTpl(corner, size, f.defOrientation, f.unitStr, f.fontDirStr, fn, f)
}
-// CreateTemplate creates a template not attached to any document
+// CreateTemplate creates a template not attached to any document (deprecated)
func CreateTemplate(corner PointType, size SizeType, unitStr, fontDirStr string, fn func(*Tpl)) Template {
- return newTpl(corner, size, unitStr, fontDirStr, fn, nil)
+ orientationStr := "p"
+ if size.Wd > size.Ht {
+ orientationStr = "l"
+ }
+
+ return CreateTpl(corner, size, orientationStr, unitStr, fontDirStr, fn)
+}
+
+// CreateTemplate creates a template not attached to any document
+func CreateTpl(corner PointType, size SizeType, orientationStr, unitStr, fontDirStr string, fn func(*Tpl)) Template {
+ return newTpl(corner, size, orientationStr, unitStr, fontDirStr, fn, nil)
}
// UseTemplate adds a template to the current page or another template,