本文整理汇总了Golang中github.com/raff/pdfreader/fancy.Reader类的典型用法代码示例。如果您正苦于以下问题:Golang Reader类的具体用法?Golang Reader怎么用?Golang Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: proceed
func proceed(i *TypeOneI, rdr fancy.Reader) {
for !i.Done {
t, _ := ps.Token(rdr)
// fmt.Printf("Stack: %v\n", util.StringArray(i.St.Dump()));
// fmt.Printf("--- %s\n", t);
if len(t) < 1 {
break
}
b, _ := rdr.ReadByte()
if b > 32 {
rdr.UnreadByte()
}
if len(t) == 0 {
break
}
if d, ok := find(i, "/"+string(t)); ok {
if d[0] == '{' {
proceed(i, fancy.SliceReader(d[1:len(d)-1]))
} else {
i.St.Push(d)
}
} else if f, ok := Ops[string(t)]; ok {
f(i)
} else {
i.St.Push(t)
}
}
return
}
开发者ID:raff,项目名称:pdfreader,代码行数:29,代码来源:type1.go
示例2: skipComment
func skipComment(f fancy.Reader) {
for {
c, err := f.ReadByte()
if err != nil || c == 13 || c == 10 {
break
}
}
}
开发者ID:raff,项目名称:pdfreader,代码行数:8,代码来源:ps.go
示例3: xrefStart
// xrefStart() queries the start of the xref-table in a PDF file.
func xrefStart(f fancy.Reader) int {
s := int(f.Size())
pdf := make([]byte, min(s, 1024))
f.ReadAt(pdf, int64(max(0, s-1024)))
ps := startxref.FindAll(pdf, -1)
if ps == nil {
return -1
}
return num(startxref.FindSubmatch(ps[len(ps)-1])[2])
}
开发者ID:raff,项目名称:pdfreader,代码行数:11,代码来源:pdfread.go
示例4: skipSpaces
func skipSpaces(f fancy.Reader) byte {
for {
c, err := f.ReadByte()
if err != nil {
break
}
if c > 32 {
return c
}
}
return 0
}
开发者ID:raff,项目名称:pdfreader,代码行数:12,代码来源:ps.go
示例5: skipString
func skipString(f fancy.Reader) {
for depth := 1; depth > 0; {
c, err := f.ReadByte()
if err != nil {
break
}
switch c {
case '(':
depth++
case ')':
depth--
case '\\':
f.ReadByte()
}
}
}
开发者ID:raff,项目名称:pdfreader,代码行数:16,代码来源:ps.go
示例6: skipToDelim
func skipToDelim(f fancy.Reader) byte {
for {
c, err := f.ReadByte()
if err != nil {
break
}
if c < 33 {
return c
}
switch c {
case '<', '>', '(', ')', '[', ']', '/', '%', '{', '}':
return c
}
}
return 255
}
开发者ID:raff,项目名称:pdfreader,代码行数:16,代码来源:ps.go
示例7: eexec
func eexec(rdr fancy.Reader) []byte {
fpos, _ := rdr.Seek(0, 1)
b := fancy.ReadAll(rdr)
cnt := 0
pos := 0
k := 0
for ; cnt < 256 && k < len(b); k++ {
switch b[k] {
case 32, 10, 13, 9:
case '0':
cnt++
default:
cnt = 0
pos = k + 1
}
}
b = b[0:pos]
rdr.Seek(fpos+int64(k), 0)
if util.IsHex(b[0]) {
b, _ = hex.DecodeString(string(b))
}
return T1Decrypt(EEXEC_KEY, b)[4:]
}
开发者ID:raff,项目名称:pdfreader,代码行数:23,代码来源:type1.go
示例8: xrefSkip
// xrefSkip() queries the start of the trailer for a (partial) xref-table.
func xrefSkip(f fancy.Reader, xref int) int {
f.Seek(int64(xref), 0)
t, p := ps.Token(f)
if string(t) != "xref" {
return -1
}
for {
t, p = ps.Token(f)
if t[0] < '0' || t[0] > '9' {
f.Seek(p, 0)
break
}
t, _ = ps.Token(f)
ps.SkipLE(f)
f.Seek(int64(num(t)*20), 1)
}
r, _ := f.Seek(0, 1)
return int(r)
}
开发者ID:raff,项目名称:pdfreader,代码行数:20,代码来源:pdfread.go
示例9: refToken
func refToken(f fancy.Reader) ([]byte, int64) {
tok, p := ps.Token(f)
if len(tok) > 0 && tok[0] >= '0' && tok[0] <= '9' {
ps.Token(f)
r, q := ps.Token(f)
if string(r) == "R" {
f.Seek(p, 0)
tok = f.Slice(int(1 + q - p))
} else {
f.Seek(p+int64(len(tok)), 0)
}
}
return tok, p
}
开发者ID:raff,项目名称:pdfreader,代码行数:14,代码来源:pdfread.go
示例10: SkipLE
func SkipLE(f fancy.Reader) {
for {
c, err := f.ReadByte()
if err != nil {
return
}
if c > 32 {
f.UnreadByte()
return
}
if c == 13 {
c, err = f.ReadByte()
if err == nil && c != 10 {
f.UnreadByte()
}
return
}
if c == 10 {
return
}
}
}
开发者ID:raff,项目名称:pdfreader,代码行数:22,代码来源:ps.go
示例11: xrefReadTable
// xrefReadTable() reads the xref table(s) of a PDF file. This is not recursive
// in favour of not to have to keep track of already used starting points
// for xrefs.
func xrefReadTable(f fancy.Reader, p int) (map[int]int, DictionaryT) {
var trailer DictionaryT
var back [MAX_PDF_UPDATES]int
b := 0
s := _Bytes
for ok := true; ok; {
back[b] = p
b++
p = xrefSkip(f, p)
f.Seek(int64(p), 0)
s, _ = ps.Token(f)
if string(s) != "trailer" {
util.Log("no trailer / xref table")
return nil, nil
}
s, _ = ps.Token(f)
if trailer == nil {
trailer = Dictionary(s)
}
s, ok = Dictionary(s)["/Prev"]
p = num(s)
}
r := make(map[int]int)
for b != 0 {
b--
f.Seek(int64(back[b]), 0)
ps.Token(f) // skip "xref"
for {
m := tuple(f, 2)
if string(m[0]) == "trailer" {
break
}
ps.SkipLE(f)
o := num(m[0])
dat := f.Slice(num(m[1]) * 20)
for i := 0; i < len(dat); i += 20 {
if dat[i+17] != 'n' {
delete(r, o)
} else {
r[o] = num(dat[i : i+10])
}
o++
}
}
}
return r, trailer
}
开发者ID:raff,项目名称:pdfreader,代码行数:50,代码来源:pdfread.go
示例12: Token
func Token(f fancy.Reader) ([]byte, int64) {
again:
c := skipSpaces(f)
if c == 0 {
return []byte{}, -1
}
p := fpos(f) - 1
switch c {
case '%':
skipComment(f)
goto again
case '<', '[', '{':
skipComposite(f)
case '(':
skipString(f)
default:
if skipToDelim(f) != 255 {
f.UnreadByte()
}
}
n := int(fpos(f) - p)
f.Seek(p, 0)
return f.Slice(n), p
}
开发者ID:raff,项目名称:pdfreader,代码行数:24,代码来源:ps.go
示例13: xrefReadStream
// xrefReadStream() reads the xref stream(s) of a PDF file. This is not recursive
// in favour of not to have to keep track of already used starting points
// for xrefs.
func xrefReadStream(f fancy.Reader, p int) (xr map[int]int, r [][2]int, trailer DictionaryT) {
s := _Bytes
xr = map[int]int{}
r = [][2]int{}
for ok := true; ok; {
f.Seek(int64(p), 0)
ps.Token(f) // skip "xref"
//for {
m := tuple(f, 2)
if string(m[1]) != "obj" {
util.Logf("unexpected %q\n", m)
return nil, nil, nil
}
s, _ = ps.Token(f)
dic := Dictionary(s)
if trailer == nil {
trailer = dic
}
s, ok = dic["/Prev"]
p = num(s)
s, _ = ps.Token(f)
if string(s) != "stream" {
util.Log("not a stream", s)
return nil, nil, nil
}
ps.SkipLE(f)
for k, v := range dic {
util.Logf("%s %s", k, v)
}
size := num(dic["/Size"])
index := []int{0, size}
if _, ok := dic["/Index"]; ok {
a := Array(dic["/Index"])
index[0] = num(a[0])
index[1] = num(a[1])
// can len(index) be != 2 ?
}
l := num(dic["/Length"])
xref := f.Slice(l)
w := Array(dic["/W"])
if len(w) != 3 {
util.Log("unexpected /W", w)
}
fl1 := num(w[0])
fl2 := num(w[1])
fl3 := num(w[2])
width := fl1 + fl2 + fl3
xref = decodeStream(dic, xref)
s, _ = ps.Token(f) // endstream
s, _ = ps.Token(f) // endobj
pos := index[0]
for i := 0; i < len(xref); i += width {
ent := xref[i : i+width]
f1 := bnum(ent[0:fl1])
f2 := bnum(ent[fl1 : fl1+fl2])
f3 := bnum(ent[fl1+fl2:])
switch f1 {
case 0:
// free object
util.Log("free", f2, f3)
// delete(r, f2)
case 1:
// regular object
util.Log("ref", pos, f3, f2)
xr[pos] = f2
case 2:
// compressed object
util.Log("cref", pos, f2, f3)
r = append(r, [2]int{f2, f3})
}
pos += 1
}
//}
}
//.........这里部分代码省略.........
开发者ID:raff,项目名称:pdfreader,代码行数:101,代码来源:pdfread.go
示例14: fpos
func fpos(f fancy.Reader) int64 {
r, _ := f.Seek(0, 1)
return r
}
开发者ID:raff,项目名称:pdfreader,代码行数:4,代码来源:ps.go
注:本文中的github.com/raff/pdfreader/fancy.Reader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论