-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathxref_data.go
More file actions
39 lines (33 loc) · 741 Bytes
/
Copy pathxref_data.go
File metadata and controls
39 lines (33 loc) · 741 Bytes
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
package pdft
import (
"errors"
"strconv"
"strings"
)
// XrefData nnnnnnnnnn ggggg x eol
type XrefData struct {
N10Digit int //nnnnnnnnnn
G5Digit int //ggggg
Keyword string //x
}
func (x *XrefData) parse(xrefline string) error {
xrefline = strings.TrimSpace(xrefline)
tokens := strings.Split(xrefline, " ")
if len(tokens) < 3 {
return errors.New("bad xref format")
}
var err error
x.N10Digit, err = strconv.Atoi(strings.TrimSpace(tokens[0]))
if err != nil {
return err
}
x.G5Digit, err = strconv.Atoi(strings.TrimSpace(tokens[1]))
if err != nil {
return err
}
x.Keyword = strings.TrimSpace(tokens[2])
if x.Keyword != "n" && x.Keyword != "f" {
return errors.New("unkonw xref keyword")
}
return nil
}