forked from signintech/gopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buff_write.go
48 lines (41 loc) · 930 Bytes
/
buff_write.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
package gopdf
import "io"
//WriteUInt32 writes a 32-bit unsigned integer value to w io.Writer
func WriteUInt32(w io.Writer, v uint) error {
a := byte(v >> 24)
b := byte(v >> 16)
c := byte(v >> 8)
d := byte(v)
_, err := w.Write([]byte{a, b, c, d})
if err != nil {
return err
}
return nil
}
//WriteUInt16 writes a 16-bit unsigned integer value to w io.Writer
func WriteUInt16(w io.Writer, v uint) error {
a := byte(v >> 8)
b := byte(v)
_, err := w.Write([]byte{a, b})
if err != nil {
return err
}
return nil
}
//WriteTag writes string value to w io.Writer
func WriteTag(w io.Writer, tag string) error {
b := []byte(tag)
_, err := w.Write(b)
if err != nil {
return err
}
return nil
}
//WriteBytes writes []byte value to w io.Writer
func WriteBytes(w io.Writer, data []byte, offset int, count int) error {
_, err := w.Write(data[offset : offset+count])
if err != nil {
return err
}
return nil
}