# tyse **Repository Path**: laogg/tyse ## Basic Information - **Project Name**: tyse - **Description**: https://github.com/npillmayer/tyse.git Experiments with formatting Text [PDF] - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-16 - **Last Updated**: 2022-05-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TySE Experiments with formatting Text # test sample ``` go func TestSimple(t *testing.T) { teardown := gotestingadapter.RedirectTracing(t) defer teardown() pdffile, err := os.Create("apitest.pdf") if err != nil { t.Error(err) } t.Log("Writing PDF to: apitest.pdf") defer pdffile.Close() helvetica := pdfapi.NewInternalFont(pdfapi.Helvetica) api := pdfapi.NewDocument() canvas := api.NewPage(pdfapi.Unit(300), pdfapi.Unit(300)) canvas.DrawLine(pdfapi.Point{0, 0}, pdfapi.Point{300, 300}) p := &pdfapi.Path{} r := pdfapi.Rectangle{pdfapi.Point{50, 100}, pdfapi.Point{250, 200}} center := pdfapi.Point{150, 150} p.Rectangle(r, 10) canvas.PushState() canvas.SetStrokeColor(color.Black) transf := pdfapi.Identity().Shifted(pdfapi.Point{-center.X, -center.Y}).Rotated( pdfapi.Deg2Rad(30)).Shifted(center) t.Logf("T = %v", transf) canvas.Transform(transf) canvas.FillStroke(p) canvas.PopState() txt := &pdfapi.Text{} txt.MoveCursor(pdfapi.Point{20, 200}) txt.SetFont(helvetica, 24) txt.AddGlyphs("Hello world!") canvas.DrawText(txt) canvas.Close() api.Assemble(canvas) api.Encode(pdffile) } ```