Пример #1
0
func Page(pd *pdfread.PdfReaderT, page int) []byte {
	pg := pd.Pages()
	if page >= len(pg) {
		complain("Page does not exist!\n")
	}
	mbox := util.StringArray(pd.Arr(pd.Att("/MediaBox", pg[page])))
	drw := svgdraw.NewTestSvg()
	svgtext.New(pd, drw).Page = page
	w := strm.Mul(strm.Sub(mbox[2], mbox[0]), "1.25")
	h := strm.Mul(strm.Sub(mbox[3], mbox[1]), "1.25")
	drw.Write.Out(
		"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"+
			"<svg\n"+
			"   xmlns:svg=\"http://www.w3.org/2000/svg\"\n"+
			"   xmlns=\"http://www.w3.org/2000/svg\"\n"+
			"   version=\"1.0\"\n"+
			"   width=\"%s\"\n"+
			"   height=\"%s\">\n"+
			"<g transform=\"matrix(1.25,0,0,-1.25,%s,%s)\">\n",
		w, h,
		strm.Mul(mbox[0], "-1.25"),
		strm.Mul(mbox[3], "1.25"))
	cont := pd.ForcedArray(pd.Dic(pg[page])["/Contents"])
	_, ps := pd.DecodedStream(cont[0])
	drw.Interpret(fancy.SliceReader(ps))
	drw.Draw.CloseDrawing()
	drw.Write.Out("</g>\n</svg>\n")
	return drw.Write.Content
}
Пример #2
0
func main() {
	a, _ := ioutil.ReadFile(os.Args[1])
	if a[0] == 128 {
		a = pfb.Decode(a)
	}
	g := type1.Read(fancy.SliceReader(a))
	fmt.Printf("%v\n", util.StringArray(g.St.Dump()))
	dumpT1(g)
}
Пример #3
0
func (t *SvgTextT) TSetMatrix(s [][]byte) {
	if s == nil {
		t.matrix = []string{"1", "0", "0", "1", "0", "0"}
	} else {
		t.matrix = util.StringArray(s)
	}
	t.x0 = "0"
	t.x = t.x0
	t.y = "0"
}