-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathimage_test.go
More file actions
57 lines (45 loc) · 1.18 KB
/
image_test.go
File metadata and controls
57 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package gopdf
import (
"os"
"testing"
"github.com/tiechui1994/gopdf/core"
)
func ComplexImageReport() {
r := core.CreateReport()
if err := r.SetPage("A4", "P"); err != nil {
panic(err)
}
r.RegisterExecutor(core.Executor(ImageReportExecutor), core.Detail)
if err := r.Execute("image_test.pdf"); err != nil {
panic(err)
}
if err := r.SaveAtomicCellText("image_test.txt"); err != nil {
panic(err)
}
}
func ImageReportExecutor(report *core.Report) {
report.Font(core.FontSansBold, 10, "")
report.SetFont(core.FontSansBold, 10)
cat := "example//pictures/cat.jpg"
rand := "example//pictures/rand.jpeg"
i1 := NewImage(rand, report)
i1.GenerateAtomicCell()
report.SetMargin(0, 5)
i2 := NewImage(cat, report)
i2.GenerateAtomicCell()
report.SetMargin(0, 5)
i3 := NewImageWithWidthAndHeight(cat, 20, 40, report)
i3.GenerateAtomicCell()
x, y := report.GetXY()
report.LineH(x, y+5, x+100)
x, y = x+0, y+40
report.Oval(x, y, x+40, y+20)
}
func TestImage(t *testing.T) {
for _, p := range []string{"example//pictures/rand.jpeg", "example//pictures/cat.jpg"} {
if _, err := os.Stat(p); err != nil {
t.Skip("image fixtures not in tree:", p)
}
}
ComplexImageReport()
}