-
Notifications
You must be signed in to change notification settings - Fork 0
/
procset_obj.go
84 lines (72 loc) · 1.63 KB
/
procset_obj.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package gopdf
import (
"bytes"
"fmt"
)
//ProcSetObj pdf procSet object
type ProcSetObj struct {
buffer bytes.Buffer
//Font
Realtes RelateFonts
RealteXobjs RealteXobjects
getRoot func() *GoPdf
}
func (pr *ProcSetObj) init(funcGetRoot func() *GoPdf) {
pr.getRoot = funcGetRoot
}
func (pr *ProcSetObj) build(objID int) error {
pr.buffer.WriteString("<<\n")
pr.buffer.WriteString("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n")
pr.buffer.WriteString("/Font <<\n")
//me.buffer.WriteString("/F1 9 0 R
//me.buffer.WriteString("/F2 12 0 R
//me.buffer.WriteString("/F3 15 0 R
i := 0
max := len(pr.Realtes)
for i < max {
realte := pr.Realtes[i]
pr.buffer.WriteString(fmt.Sprintf(" /F%d %d 0 R\n", realte.CountOfFont+1, realte.IndexOfObj+1))
i++
}
pr.buffer.WriteString(">>\n")
pr.buffer.WriteString("/XObject <<\n")
i = 0
max = len(pr.RealteXobjs)
for i < max {
pr.buffer.WriteString(fmt.Sprintf("/I%d %d 0 R\n", pr.getRoot().curr.CountOfL+1, pr.RealteXobjs[i].IndexOfObj+1))
pr.getRoot().curr.CountOfL++
i++
}
pr.buffer.WriteString(">>\n")
pr.buffer.WriteString(">>\n")
return nil
}
func (pr *ProcSetObj) getType() string {
return "ProcSet"
}
func (pr *ProcSetObj) getObjBuff() *bytes.Buffer {
return &(pr.buffer)
}
type RelateFonts []RelateFont
func (re *RelateFonts) IsContainsFamily(family string) bool {
i := 0
max := len(*re)
for i < max {
if (*re)[i].Family == family {
return true
}
i++
}
return false
}
type RelateFont struct {
Family string
//etc /F1
CountOfFont int
//etc 5 0 R
IndexOfObj int
}
type RealteXobjects []RealteXobject
type RealteXobject struct {
IndexOfObj int
}