summaryrefslogtreecommitdiff
path: root/template.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2019-09-07 09:17:24 -0400
committerKurt <kurt.w.jung@gmail.com>2019-09-07 09:17:24 -0400
commitfac5b8ac092fabeb667ca3e16212b5cc2fc0c4f1 (patch)
tree08ec04cb4469d1685189545b70ee3749ba420e76 /template.go
parentced1e15bca902f15732b6380aaa4bdc419d87eac (diff)
parent29a8ebcc82176b98972f23e915f2afdf8a192bac (diff)
Merge branch 'joewestcott-template-init'
Diffstat (limited to 'template.go')
-rw-r--r--template.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/template.go b/template.go
index 31204c2..c0d3933 100644
--- a/template.go
+++ b/template.go
@@ -84,7 +84,18 @@ func (f *Fpdf) UseTemplateScaled(t Template, corner PointType, size SizeType) {
for _, tt := range t.Templates() {
f.templates[tt.ID()] = tt
}
+
+ // Create a list of existing image SHA-1 hashes.
+ existingImages := map[string]bool{}
+ for _, image := range f.images {
+ existingImages[image.i] = true
+ }
+
+ // Add each template image to $f, unless already present.
for name, ti := range t.Images() {
+ if _, found := existingImages[ti.i]; found {
+ continue
+ }
name = sprintf("t%s-%s", t.ID(), name)
f.images[name] = ti
}