-
Notifications
You must be signed in to change notification settings - Fork 0
/
device_rgb_obj.go
50 lines (42 loc) · 1001 Bytes
/
device_rgb_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
package gopdf
import (
"bytes"
"strconv"
)
//DeviceRGBObj DeviceRGB
type DeviceRGBObj struct {
buffer bytes.Buffer
data []byte
getRoot func() *GoPdf
}
func (d *DeviceRGBObj) init(funcGetRoot func() *GoPdf) {
d.getRoot = funcGetRoot
}
func (d *DeviceRGBObj) protection() *PDFProtection {
return d.getRoot().protection()
}
func (d *DeviceRGBObj) getType() string {
return "devicergb"
}
func (d *DeviceRGBObj) getObjBuff() *bytes.Buffer {
return &d.buffer
}
//สร้าง ข้อมูลใน pdf
func (d *DeviceRGBObj) build(objID int) error {
d.buffer.WriteString("<<\n")
d.buffer.WriteString("/Length " + strconv.Itoa(len(d.data)) + "\n")
d.buffer.WriteString(">>\n")
d.buffer.WriteString("stream\n")
if d.protection() != nil {
tmp, err := rc4Cip(d.protection().objectkey(objID), d.data)
if err != nil {
return err
}
d.buffer.Write(tmp)
d.buffer.WriteString("\n")
} else {
d.buffer.Write(d.data)
}
d.buffer.WriteString("endstream\n")
return nil
}