draw2d/draw2dpdf
Laurent Le Goff 7ef94ce784 Merge branch 'master' into Clean-Up
Conflicts:
	arc.go
	curve/curve_test.go
	draw2dgl/gc.go
	draw2dimg/rgba_interpolation.go
	draw2dpdf/gc.go
	draw2dpdf/path_converter.go
	path_adder.go
	path_storage.go
	raster/raster_test.go
	vertex2d.go
2015-08-14 21:40:32 +02:00
..
README.md Add README to draw2dpdf 2015-07-12 03:03:27 +02:00
doc.go use filenames in examples README 2015-07-12 03:04:30 +02:00
fileutil.go add copyright information 2015-07-10 15:11:19 +02:00
gc.go Merge branch 'master' into Clean-Up 2015-08-14 21:40:32 +02:00
path_converter.go fix arc angle bug 2015-07-11 18:39:51 +02:00
samples_test.go add geometry and gopher2 samples 2015-07-11 18:44:36 +02:00
test_test.go update readme 2015-07-11 22:53:24 +02:00
vectorizer.go rename pdf2d to draw2dpdf 2015-07-07 00:25:56 +02:00

README.md

draw2d pdf

Package draw2dpdf provides a graphic context that can draw vector graphics and text on pdf file with the gofpdf package.

Quick Start

The following Go code generates a simple drawing and saves it to a pdf document:

// Initialize the graphic context on an RGBA image
dest := draw2dpdf.NewPdf("L", "mm", "A4")
gc := draw2d.NewGraphicContext(dest)

// Set some properties
gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff})
gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff})
gc.SetLineWidth(5)

// Draw a closed shape
gc.MoveTo(10, 10) // should always be called first for a new path
gc.LineTo(100, 50)
gc.QuadCurveTo(100, 10, 10, 10)
gc.Close()
gc.FillStroke()

// Save to file
draw2dpdf.SaveToPdfFile("hello.pdf", dest)

There are more examples here: https://github.com/llgcode/draw2d/tree/master/samples

Alternative backends

  • Drawing on images is provided by the draw2d package.
  • Drawing on opengl is provided by the draw2dgl package.

Acknowledgments

The pdf backend uses https://github.com/jung-kurt/gofpdf