forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_rgb_obj.go
46 lines (38 loc) · 860 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
package gopdf
import (
"fmt"
"io"
)
//DeviceRGBObj DeviceRGB
type DeviceRGBObj struct {
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"
}
//สร้าง ข้อมูลใน pdf
func (d *DeviceRGBObj) write(w io.Writer, objID int) error {
io.WriteString(w, "<<\n")
fmt.Fprintf(w, "/Length %d\n", len(d.data))
io.WriteString(w, ">>\n")
io.WriteString(w, "stream\n")
if d.protection() != nil {
tmp, err := rc4Cip(d.protection().objectkey(objID), d.data)
if err != nil {
return err
}
w.Write(tmp)
io.WriteString(w, "\n")
} else {
w.Write(d.data)
}
io.WriteString(w, "endstream\n")
return nil
}