func (t *TypeOneI) NewDic() (r []byte) { rs := fmt.Sprintf("D%d", t.DicNo) r = util.Bytes(rs) t.Dicts[t.DicNo] = new(DicT) t.Dicts[t.DicNo].Defs = make(map[string][]byte) t.Dicts[t.DicNo].Name = r t.DicNo++ return }
func main() { pd := pdfread.Load(os.Args[1]) _, d := pd.DecodedStream(util.Bytes(os.Args[2])) fmt.Printf("%s", d) /* a := cmapi.Read(fancy.SliceReader(d)); fmt.Printf("\n%v\n%v\n%v\n", a, a.Ranges, a.Uni); */ }
}, "'": func(pd *PdfDrawerT) { pd.Text.TNextLine() pd.Text.TShow(pd.Stack.Pop()) }, "BT": func(pd *PdfDrawerT) { pd.Text.TSetMatrix(nil) }, "ET": func(pd *PdfDrawerT) { }, "T*": func(pd *PdfDrawerT) { pd.Text.TNextLine() }, "TD": func(pd *PdfDrawerT) { a := pd.Stack.Drop(2) pd.TConf.SetLeading(util.Bytes(strm.Neg(string(a[1])))) pd.Text.TMoveTo(a) }, "TJ": func(pd *PdfDrawerT) { pd.Text.TShow(pd.Stack.Pop()) }, "Td": func(pd *PdfDrawerT) { a := pd.Stack.Drop(2) pd.Text.TMoveTo(a) }, "Tj": func(pd *PdfDrawerT) { pd.Text.TShow(pd.Stack.Pop()) }, "Tm": func(pd *PdfDrawerT) { a := pd.Stack.Drop(6) pd.Text.TSetMatrix(a)
func (t *TypeOneI) NewArray(size int) (r []byte) { r = util.Bytes(fmt.Sprintf("A%d", t.ArraNo)) t.Arrays[t.ArraNo] = make([][]byte, size) t.ArraNo++ return }
func init() { var ops = map[string]func(t *TypeOneI){ "array": func(t *TypeOneI) { a := t.St.Pop() t.St.Push(t.NewArray(strm.Int(string(a), 1))) }, "begin": func(t *TypeOneI) { a := t.St.Pop() if a[0] != 'D' { panic("Wrong dictionary!\n") } t.DicSp++ t.DicSt[t.DicSp] = t.Dicts[strm.Int(string(a[1:]), 1)] }, "bind": func(t *TypeOneI) { }, "cleartomark": func(t *TypeOneI) { a := t.St.Pop() for string(a) != "mark" { a = t.St.Pop() } }, "closefile": func(t *TypeOneI) { a := t.St.Pop() t.Done = true _ = a }, "currentdict": func(t *TypeOneI) { t.St.Push(t.DicSt[t.DicSp].Name) }, "currentfile": func(t *TypeOneI) { t.St.Push([]byte{'?'}) }, "def": func(t *TypeOneI) { a := t.St.Drop(2) t.DicSt[t.DicSp].Defs[string(a[0])] = a[1] }, "definefont": func(t *TypeOneI) { a := t.St.Drop(2) t.Fonts[string(a[0])] = string(a[1]) t.St.Push(util.Bytes("<FONT>")) // FIXME, we need this. _ = a }, "defineresource": func(t *TypeOneI) { a := t.St.Drop(3) t.St.Push([]byte{'?'}) _ = a }, "dict": func(t *TypeOneI) { a := t.St.Pop() t.St.Push(t.NewDic()) _ = a }, "dup": func(t *TypeOneI) { a := t.St.Pop() t.St.Push(a) t.St.Push(a) }, "eexec": func(t *TypeOneI) { a := t.St.Pop() b := eexec(t.Rdr) old := t.Rdr t.Rdr = fancy.SliceReader(b) //proceed(t, t.Rdr) t.Rdr = old t.Done = false _ = a }, "end": func(t *TypeOneI) { t.DicSp-- }, "exch": func(t *TypeOneI) { a := t.St.Drop(2) a0 := a[0] t.St.Push(a[1]) t.St.Push(a0) }, "executeonly": func(t *TypeOneI) { }, "findresource": func(t *TypeOneI) { a := t.St.Drop(2) t.St.Push([]byte{'?'}) _ = a }, "for": func(t *TypeOneI) { a := t.St.Drop(4) // FIXME _ = a }, "get": func(t *TypeOneI) { a := t.St.Drop(2) i := strm.Int(string(a[0][1:]), 1) if a[0][0] == 'D' { t.St.Push(t.Dicts[i].Defs[string(a[1])]) } else if a[0][0] == 'A' { t.St.Push(t.Arrays[i][strm.Int(string(a[1]), 1)]) } else { panic("Can not 'get' from!\n") } }, "if": func(t *TypeOneI) { a := t.St.Drop(2) t.op_ifelse([][]byte{a[0], a[1], []byte{}}) }, "ifelse": func(t *TypeOneI) { a := t.St.Drop(3) t.op_ifelse(a) }, "index": func(t *TypeOneI) { a := t.St.Pop() t.St.Push(t.St.Index(strm.Int(string(a), 1) + 1)) }, "known": func(t *TypeOneI) { a := t.St.Drop(2) t.St.Push(util.Bytes("false")) // FIX ME knows nothing ;) _ = a }, "noaccess": func(t *TypeOneI) { }, "pop": func(t *TypeOneI) { a := t.St.Pop() _ = a }, "put": func(t *TypeOneI) { a := t.St.Drop(3) if a[0][0] == 'D' { t.Dicts[strm.Int(string(a[0][1:]), 1)].Defs[string(a[1])] = a[2] } else if a[0][0] == 'A' { t.Arrays[strm.Int(string(a[0][1:]), 1)][strm.Int(string(a[1]), 1)] = a[2] } else { panic("Wrong dictionary or array!\n") } }, "readonly": func(t *TypeOneI) { }, "readstring": func(t *TypeOneI) { a := t.St.Drop(2) c, _ := t.Rdr.Read(a[1]) t.St.Push(a[1][0:c]) t.St.Push(util.Bytes("true")) }, "string": func(t *TypeOneI) { a := t.St.Pop() t.St.Push(make([]byte, strm.Int(string(a), 1))) }, "userdict": func(t *TypeOneI) { t.St.Push(util.Bytes("D0")) }, "where": func(t *TypeOneI) { a := t.St.Pop() t.St.Push(util.Bytes("false")) _ = a }, } for k, v := range ops { Ops[k] = v } }