forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smask_obj.go
54 lines (44 loc) · 909 Bytes
/
smask_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
package gopdf
import (
"fmt"
"io"
)
//SMask smask
type SMask struct {
imgInfo
data []byte
//getRoot func() *GoPdf
pdfProtection *PDFProtection
}
func (s *SMask) init(funcGetRoot func() *GoPdf) {
//s.getRoot = funcGetRoot
}
func (s *SMask) setProtection(p *PDFProtection) {
s.pdfProtection = p
}
func (s *SMask) protection() *PDFProtection {
return s.pdfProtection
}
func (s *SMask) getType() string {
return "smask"
}
func (s *SMask) write(w io.Writer, objID int) error {
err := writeImgProp(w, s.imgInfo)
if err != nil {
return err
}
fmt.Fprintf(w, "/Length %d\n>>\n", len(s.data)) // /Length 62303>>\n
io.WriteString(w, "stream\n")
if s.protection() != nil {
tmp, err := rc4Cip(s.protection().objectkey(objID), s.data)
if err != nil {
return err
}
w.Write(tmp)
io.WriteString(w, "\n")
} else {
w.Write(s.data)
}
io.WriteString(w, "\nendstream\n")
return nil
}