forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pages_obj.go
47 lines (35 loc) · 965 Bytes
/
pages_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
package gopdf
import (
"bytes"
"fmt"
"strconv"
)
type PagesObj struct { //impl IObj
buffer bytes.Buffer
PageCount int
Kids string
getRoot func()(*GoPdf)
}
func (me *PagesObj) Init(funcGetRoot func()(*GoPdf)) {
me.PageCount = 0
me.getRoot = funcGetRoot
}
func (me *PagesObj) Build() {
height := fmt.Sprintf("%0.2f",me.getRoot().config.PageSize.H);
width := fmt.Sprintf("%0.2f",me.getRoot().config.PageSize.W);
me.buffer.WriteString("<<\n")
me.buffer.WriteString(" /Type /" + me.GetType() + "\n")
me.buffer.WriteString(" /MediaBox [ 0 0 "+width+" "+height+" ]\n")
me.buffer.WriteString(" /Count "+strconv.Itoa(me.PageCount)+"\n")
me.buffer.WriteString(" /Kids [ "+me.Kids+" ]\n") //sample Kids [ 3 0 R ]
me.buffer.WriteString(">>\n")
}
func (me *PagesObj) GetType() string {
return "Pages"
}
func (me *PagesObj) GetObjBuff() *bytes.Buffer {
return &(me.buffer)
}
func (me *PagesObj) Test() {
fmt.Print(me.GetType() + "\n")
}