diff options
author | Joop Kiefte <ikojba@gmail.com> | 2016-06-03 08:56:38 +0200 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2016-06-03 08:56:38 +0200 |
commit | ff6c9ff65dfc8fed4b5420278c99db2c73351f61 (patch) | |
tree | e2da7dcdeacc74e01e9f90023f76ee7478115efe |
Initial commit
-rw-r--r-- | main.go | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -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) + } +} |