diff --git a/pdf2d/samples/helloworld/helloworld.go b/pdf2d/samples/helloworld/helloworld.go new file mode 100644 index 0000000..42263f4 --- /dev/null +++ b/pdf2d/samples/helloworld/helloworld.go @@ -0,0 +1,38 @@ +// 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) +} diff --git a/pdf2d/samples/helloworld/luximbi.json b/pdf2d/samples/helloworld/luximbi.json new file mode 100644 index 0000000..a03565e --- /dev/null +++ b/pdf2d/samples/helloworld/luximbi.json @@ -0,0 +1 @@ +{"Tp":"TrueType","Name":"LuxiMono-BoldOblique","Desc":{"Ascent":783,"Descent":-205,"CapHeight":783,"Flags":97,"FontBBox":{"Xmin":-29,"Ymin":-211,"Xmax":764,"Ymax":1012},"ItalicAngle":-8,"StemV":120,"MissingWidth":600},"Up":0,"Ut":0,"Cw":[600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,653,600,653,600,600,653,600,653,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600,600],"Enc":"cp1252","Diff":"","File":"","Size1":0,"Size2":0,"OriginalSize":0,"I":0,"N":0,"DiffN":0} \ No newline at end of file diff --git a/pdf2d/samples/helloworld/luximbi.ttf b/pdf2d/samples/helloworld/luximbi.ttf new file mode 100644 index 0000000..734201b Binary files /dev/null and b/pdf2d/samples/helloworld/luximbi.ttf differ