// Copyright 2010 The draw2d Authors. All rights reserved. // created: 21/11/2010 by Laurent Le Goff, Stani Michiels // Display Hello world in a Rectangle save it to a png package main import ( "image" "github.com/stanim/draw2d" "github.com/stanim/draw2d/pdf2d" ) func main() { // Set the global folder for searching fonts // The pdf backend needs for every ttf file its corresponding json // file which is generated by gofpdf/makefont. draw2d.SetFontFolder(".") // Initialize the graphic context on a pdf document dest := pdf2d.NewPdf("P", "mm", "A4") gc := pdf2d.NewGraphicContext(dest) // Draw a rounded rectangle using default colors draw2d.RoundRect(gc, 5, 5, 135, 95, 10, 10) gc.FillStroke() // Set the font luximbi.ttf gc.SetFontData(draw2d.FontData{"luxi", draw2d.FontFamilyMono, draw2d.FontStyleBold | draw2d.FontStyleItalic}) // Set the fill text color to black gc.SetFillColor(image.Black) gc.SetFontSize(14) // Display Hello World gc.FillStringAt("Hello World", 8, 52) // Save to pdf pdf2d.SaveToPdfFile("helloworld.pdf", dest) }