-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathimage_test.go
59 lines (46 loc) · 1.13 KB
/
image_test.go
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
58
59
package gopdf
import (
"testing"
"github.com/tiechui1994/gopdf/core"
)
const (
IMAGE_IG = "IPAexG"
IMAGE_MD = "MPBOLD"
)
func ComplexImageReport() {
r := core.CreateReport()
font1 := core.FontMap{
FontName: IMAGE_IG,
FileName: "example//ttf/ipaexg.ttf",
}
font2 := core.FontMap{
FontName: IMAGE_MD,
FileName: "example//ttf/mplus-1p-bold.ttf",
}
r.SetFonts([]*core.FontMap{&font1, &font2})
r.SetPage("A4", "P")
r.RegisterExecutor(core.Executor(ImageReportExecutor), core.Detail)
r.Execute("image_test.pdf")
r.SaveAtomicCellText("image_test.txt")
}
func ImageReportExecutor(report *core.Report) {
report.Font(DIV_MD, 10, "")
report.SetFont(DIV_MD, 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) {
ComplexImageReport()
}