summaryrefslogtreecommitdiff
path: root/template_impl.go
diff options
context:
space:
mode:
Diffstat (limited to 'template_impl.go')
-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.