diff options
author | d1ngd0 <paul.david.montag@gmail.com> | 2018-11-01 10:31:48 -0500 |
---|---|---|
committer | Kurt Jung <kurt.w.jung@gmail.com> | 2018-11-01 11:31:48 -0400 |
commit | 1e278c483c1f927b37a1ffd8e4d98b2c0b22a3d3 (patch) | |
tree | b92b1f08fe905bfd66b4bb2400924561b6e7d5db | |
parent | ff1cd8e5b8ca41d73b5f75b21ee698cd1ef14241 (diff) |
orientation of a template is now defined by the parent document. depricated CreateTemplate (#207)
-rw-r--r-- | template.go | 18 | ||||
-rw-r--r-- | template_impl.go | 6 |
2 files changed, 15 insertions, 9 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, diff --git a/template_impl.go b/template_impl.go index 01bb040..76c5019 100644 --- a/template_impl.go +++ b/template_impl.go @@ -18,11 +18,7 @@ package gofpdf */ // newTpl creates a template, copying graphics settings from a template if one is given -func newTpl(corner PointType, size SizeType, unitStr, fontDirStr string, fn func(*Tpl), copyFrom *Fpdf) Template { - orientationStr := "p" - if size.Wd > size.Ht { - orientationStr = "l" - } +func newTpl(corner PointType, size SizeType, orientationStr, unitStr, fontDirStr string, fn func(*Tpl), copyFrom *Fpdf) Template { sizeStr := "" fpdf := fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr, size) |