-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages_obj.go
45 lines (37 loc) · 1014 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"
)
//PagesObj pdf pages object
type PagesObj struct { //impl IObj
buffer bytes.Buffer
PageCount int
Kids string
getRoot func() *GoPdf
}
func (p *PagesObj) init(funcGetRoot func() *GoPdf) {
p.PageCount = 0
p.getRoot = funcGetRoot
}
func (p *PagesObj) build(objID int) error {
height := fmt.Sprintf("%0.2f", p.getRoot().config.PageSize.H)
width := fmt.Sprintf("%0.2f", p.getRoot().config.PageSize.W)
p.buffer.WriteString("<<\n")
p.buffer.WriteString(" /Type /" + p.getType() + "\n")
p.buffer.WriteString(" /MediaBox [ 0 0 " + width + " " + height + " ]\n")
p.buffer.WriteString(" /Count " + strconv.Itoa(p.PageCount) + "\n")
p.buffer.WriteString(" /Kids [ " + p.Kids + " ]\n") //sample Kids [ 3 0 R ]
p.buffer.WriteString(">>\n")
return nil
}
func (p *PagesObj) getType() string {
return "Pages"
}
func (p *PagesObj) getObjBuff() *bytes.Buffer {
return &(p.buffer)
}
func (p *PagesObj) test() {
fmt.Print(p.getType() + "\n")
}