summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Montag <pmontag@iseeme.com>2018-11-05 15:50:58 -0600
committerPaul Montag <pmontag@iseeme.com>2018-11-05 15:50:58 -0600
commit6993fe6ea4223dca30d0cae9fa0bd9a3cdfdb12d (patch)
tree49ac575f35d488070e627e99dbf5ebe07b10de8c
parentbb287515d3b5c5b4ca7665a64a9224e8b6038804 (diff)
fixed pointer values when mutltiple templates are used
-rw-r--r--template_impl.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/template_impl.go b/template_impl.go
index 9e5d496..b1b2382 100644
--- a/template_impl.go
+++ b/template_impl.go
@@ -3,6 +3,7 @@ package gofpdf
import (
"bytes"
"encoding/gob"
+ "reflect"
)
/*
@@ -136,9 +137,26 @@ func (t *FpdfTpl) GobDecode(buf []byte) error {
}
}
+ t.relinkPointers(t.images)
+
return err
}
+func (t *FpdfTpl) relinkPointers(images map[string]*ImageInfoType) {
+ for gKey, _ := range images {
+ for key, _ := range t.images {
+ if reflect.DeepEqual(t.images[key], images[gKey]) {
+ t.images[key] = images[gKey]
+ }
+ }
+ }
+
+ for x := 0; x < len(t.templates); x++ {
+ innerT := t.templates[x].(*FpdfTpl)
+ innerT.relinkPointers(t.images)
+ }
+}
+
// Tpl is an Fpdf used for writing a template. It has most of the facilities of
// an Fpdf, but cannot add more pages. Tpl is used directly only during the
// limited time a template is writable.