summaryrefslogtreecommitdiff
path: root/template.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@gmail.com>2015-10-11 13:23:37 -0400
committerKurt Jung <kurt.w.jung@gmail.com>2015-10-11 13:23:37 -0400
commit13a5fda5f79f2c15eea512e6ec3de2ce60aa29ca (patch)
treef513ff36d45b5961007725e3e135dec258a4b7f9 /template.go
parent08c842eee7361c4d515301a5d84d246a0b0a9462 (diff)
Conditionally sort two map iterations in template code; more to come.
Diffstat (limited to 'template.go')
-rw-r--r--template.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/template.go b/template.go
index 342032e..bf25c9f 100644
--- a/template.go
+++ b/template.go
@@ -17,6 +17,10 @@ package gofpdf
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+import (
+ "sort"
+)
+
// 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)
@@ -135,8 +139,21 @@ func (f *Fpdf) putTemplates() {
tTemplates := t.Templates()
if len(tImages) > 0 || len(tTemplates) > 0 {
f.out("/XObject <<")
- for _, ti := range tImages {
- f.outf("/I%d %d 0 R", ti.i, ti.n)
+ {
+ var key string
+ var keyList []string
+ var ti *ImageInfoType
+ for key = range tImages {
+ keyList = append(keyList, key)
+ }
+ if gl.catalogSort {
+ sort.Strings(keyList)
+ }
+ for _, key = range keyList {
+ // for _, ti := range tImages {
+ ti = tImages[key]
+ f.outf("/I%d %d 0 R", ti.i, ti.n)
+ }
}
for _, tt := range tTemplates {
id := tt.ID()