Example #1
0
func main() {
	asHtml := flag.Bool("html", false, "output as html (true) or xml (false)")
	debug := flag.Bool("debug", false, "debug mode")
	page := flag.Int("page", 0, "page number")

	flag.Parse()

	if *page < 0 {
		complain("Bad page!\n\n")
	}

	if flag.NArg() != 1 {
		complain("")
	}

	pd := pdfread.Load(flag.Arg(0))
	if pd == nil {
		complain("Could not load pdf file!\n\n")
	}

	util.Debug = *debug

	if *asHtml {
		fmt.Printf("<!DOCTYPE html><html><body>\n%s</body></html>\n", svg.Page(pd, *page, false))
	} else {
		fmt.Printf("%s", svg.Page(pd, *page, true))
	}
}
Example #2
0
// 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, true))
}