From ff6c9ff65dfc8fed4b5420278c99db2c73351f61 Mon Sep 17 00:00:00 2001 From: Joop Kiefte Date: Fri, 3 Jun 2016 08:56:38 +0200 Subject: Initial commit --- main.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..c1f5211 --- /dev/null +++ b/main.go @@ -0,0 +1,33 @@ +package main + +import "github.com/jung-kurt/gofpdf" + +var tr func(string) string + +func line(pdf *gofpdf.Fpdf, jump, width float64, text string) { + pdf.SetX(jump) + pdf.MultiCell(width, 0.19, tr(text), "", "aligned", false) +} + +func main() { + pdf := gofpdf.New("P", "in", "Letter", "") + tr = pdf.UnicodeTranslatorFromDescriptor("") + pdf.AddPage() + pdf.SetFont("courier", "", 12) + pdf.SetMargins(1, 1, 1) + pdf.SetXY(1, 1) + line(pdf, 1.5, 6, "FADE IN") + line(pdf, 1.5, 6, "") + line(pdf, 1.5, 6, "A RIVER") + line(pdf, 1.5, 6, "") + line(pdf, 1.5, 6, "We’re underwater, watching a fat catfish swim along.") + line(pdf, 1.5, 6, "") + line(pdf, 1.5, 6, "This is The Beast.") + line(pdf, 1.5, 6, "") + line(pdf, 4.2, 3.3, "EDWARD (V.O.)") + line(pdf, 2.9, 3.3, "There are some fish that cannot be caught. It’s not that they’re faster or stronger than other fish. They’re just touched by something extra. Call it luck. Call it grace. One such fish was The Beast.") + err := pdf.OutputFileAndClose("hello.pdf") + if err != nil { + panic(err) + } +} -- cgit v1.2.3-70-g09d2