summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorPaul Montag <pmontag@iseeme.com>2018-10-31 19:56:01 -0500
committerPaul Montag <pmontag@iseeme.com>2018-10-31 19:56:01 -0500
commitbb287515d3b5c5b4ca7665a64a9224e8b6038804 (patch)
tree1fda5188725bdb5790afd8019b83c97b1802b3c6 /fpdf_test.go
parent6421d61dcdc4da19badab16dc2a8af331c4fbbeb (diff)
Added Ability to turn template into a byte string
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 4774ec6..e212d95 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -19,6 +19,7 @@ package gofpdf_test
import (
"bufio"
"bytes"
+ "encoding/gob"
"fmt"
"io"
"io/ioutil"
@@ -1950,10 +1951,23 @@ func ExampleFpdf_CreateTemplate() {
pdf.SetLineWidth(2.5)
pdf.SetFont("Arial", "B", 16)
+ template3 := new(gofpdf.FpdfTpl)
+ b := new(bytes.Buffer)
+ enc := gob.NewEncoder(b)
+
+ if err := enc.Encode(template); err != nil {
+ pdf.SetError(err)
+ }
+
+ dec := gob.NewDecoder(b)
+ if err := dec.Decode(template3); err != nil {
+ pdf.SetError(err)
+ }
+
pdf.AddPage()
- pdf.UseTemplate(template)
- pdf.UseTemplateScaled(template, gofpdf.PointType{X: 0, Y: 30}, tplSize)
- pdf.UseTemplateScaled(template, gofpdf.PointType{X: 0, Y: 60}, tplSize.ScaleBy(1.4))
+ pdf.UseTemplate(template3)
+ pdf.UseTemplateScaled(template3, gofpdf.PointType{X: 0, Y: 30}, tplSize)
+ pdf.UseTemplateScaled(template3, gofpdf.PointType{X: 0, Y: 60}, tplSize.ScaleBy(1.4))
pdf.Line(40, 210, 60, 210)
pdf.Text(40, 200, "Template example page 1")