summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2018-11-10 11:03:08 -0500
committerKurt <kurt.w.jung@gmail.com>2018-11-10 11:03:08 -0500
commit7c87ab704eb556bd5ec58197619c9f572d63486b (patch)
tree22f1efd1e5c47132092c8b524db5b3735254fa55 /fpdf_test.go
parent2253c0aa4a1566727231123793a2eda56c571c8f (diff)
Demonstrate page boxes
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 4774ec6..3618fc6 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -2189,3 +2189,30 @@ func ExampleNewGrid() {
// Output:
// Successfully generated pdf/Fpdf_Grid.pdf
}
+
+func pagebox(pdf *gofpdf.Fpdf, boxstr string, x, y, wd, ht float64) {
+ pdf.SetPageBox(boxstr, gofpdf.PageBox{gofpdf.SizeType{Wd: wd, Ht: ht}, gofpdf.PointType{X: x, Y: y}})
+}
+
+// This example demonstrates the use of a page box
+func ExamplePageBox() {
+ const (
+ wd = 210
+ ht = 297
+ boxmargin = 5
+ )
+ pdf := gofpdf.New("P", "mm", "A4", "") // 210mm x 297mm
+ pagebox(pdf, "bleed", 0, 0, wd, ht)
+ pagebox(pdf, "trim", boxmargin, boxmargin, wd-2*boxmargin, ht-2*boxmargin)
+ pdf.SetFont("Arial", "", 12)
+ pdf.SetDrawColor(40, 40, 40)
+ pdf.AddPage()
+ pdf.Rect(0, 0, wd, ht, "D")
+ pdf.Line(0, 0, wd, ht)
+ pdf.Line(0, ht, wd, 0)
+ fileStr := example.Filename("Fpdf_PageBox")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated pdf/Fpdf_PageBox.pdf
+}