summaryrefslogtreecommitdiff
path: root/template.go
diff options
context:
space:
mode:
Diffstat (limited to 'template.go')
-rw-r--r--template.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/template.go b/template.go
index 9abdf62..d27bc40 100644
--- a/template.go
+++ b/template.go
@@ -24,17 +24,33 @@ 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 that is not attached to any document.
+//
+// This function is deprecated; it incorrectly assumes that a page with a width
+// smaller than its height is oriented in portrait mode, otherwise it assumes
+// landscape mode. This causes problems when placing the template in a master
+// document where this condition does not apply. CreateTpl() is a similar
+// function that lets you specify the orientation to avoid this problem.
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)
+}
+
+// CreateTpl 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,