func (i *TypeOneI) Dic(id string) map[string][]byte { if id[0] != 'D' { panic("Wrong dictionary!\n") } idn := strm.Int(id[1:], 1) return i.Dicts[idn].Defs }
func (t *SvgTextT) widths(font string) (r *cmapt.CMapT) { if t.fontw == nil { t.fontw = make(map[string]*cmapt.CMapT) } else if r, ok := t.fontw[font]; ok { return r } // initialize like for Courier. r = cmapt.New() r.AddDef(0, 256, 600*WIDTH_DENSITY/1000) if t.fonts == nil { t.fonts = t.Pdf.PageFonts(t.Pdf.Pages()[t.Page]) if t.fonts == nil { return } } if dr, ok := t.fonts[font]; ok { d := t.Pdf.Dic(dr) fc, ok := d["/FirstChar"] if !ok { return } lc, ok := d["/LastChar"] if !ok { return } wd, ok := d["/Widths"] if !ok { return } p := strm.Int(string(fc), 1) q := strm.Int(string(lc), 1) a := t.Pdf.Arr(wd) for k := p; k < q; k++ { r.Add(k, strm.Int(string(a[k-p]), WIDTH_DENSITY/1000)) } } return }
func main() { if len(os.Args) == 1 || len(os.Args) > 3 { complain("") } page := 0 if len(os.Args) > 2 { page = strm.Int(os.Args[2], 1) - 1 if page < 0 { complain("Bad page!\n\n") } } pd := pdfread.Load(os.Args[1]) if pd == nil { complain("Could not load pdf file!\n\n") } fmt.Printf("%s", svg.Page(pd, page)) }
// hello world, the web server func HelloServer(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "image/svg+xml; charset=utf-8") page := strm.Int(req.URL.RawQuery, 1) - 1 w.Write(svg.Page(pd, page)) }
} func (t *TypeOneI) op_ifelse(a [][]byte) { p := a[2] if string(a[0]) == "true" { p = a[1] } if len(p) > 2 && p[0] == '{' { proceed(t, fancy.SliceReader(p[1:len(p)-1])) } } 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()