summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@code.google.com>2014-09-16 22:38:49 -0400
committerKurt Jung <kurt.w.jung@code.google.com>2014-09-16 22:38:49 -0400
commitcbbfe21f94ea53f0800feaf4e9c06c038ddc1e6e (patch)
tree952009ff7b8098e3ffc10c96fe88887e7a78ffa4 /fpdf_test.go
parent9f16b52334238f446dbafcbe06ffff0637403361 (diff)
Added layer functionality. This allows content to be placed into layers, the visibility of which can be controlled from the document reader.
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 0da5e73..964985d 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -1246,3 +1246,42 @@ func ExampleFpdf_tutorial25() {
// Output:
// Successfully generated pdf/tutorial25.pdf
}
+
+// This example demonstrates document layers. The initial visibility of a layer
+// is specified with the second parameter to AddLayer(). The layer list
+// displayed by the document reader allows layer visibility to be controlled
+// interactively.
+func ExampleFpdf_tutorial26() {
+
+ pdf := gofpdf.New("P", "mm", "A4", "")
+ pdf.AddPage()
+ pdf.SetFont("Arial", "", 15)
+ pdf.Write(8, "This line doesn't belong to any layer.\n")
+
+ // Define layers
+ l1 := pdf.AddLayer("Layer 1", true)
+ l2 := pdf.AddLayer("Layer 2", true)
+
+ // Open layer pane in PDF viewer
+ pdf.OpenLayerPane()
+
+ // First layer
+ pdf.BeginLayer(l1)
+ pdf.Write(8, "This line belongs to layer 1.\n")
+ pdf.EndLayer()
+
+ // Second layer
+ pdf.BeginLayer(l2)
+ pdf.Write(8, "This line belongs to layer 2.\n")
+ pdf.EndLayer()
+
+ // First layer again
+ pdf.BeginLayer(l1)
+ pdf.Write(8, "This line belongs to layer 1 again.\n")
+ pdf.EndLayer()
+
+ pdf.OutputAndClose(docWriter(pdf, 26))
+
+ // Output:
+ // Successfully generated pdf/tutorial26.pdf
+}