summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2018-04-15 14:15:23 -0400
committerKurt <kurt.w.jung@gmail.com>2018-04-15 14:15:23 -0400
commit892fe1b63b9a9f0b7bcdcdcdeb96cb6fe0d0a2bb (patch)
treea36ff2b45416a5e96172e015135ad624a805c07d /fpdf.go
parentf2f3e9500092af921abde270a026e8ceb2098ec4 (diff)
Add SetHeaderFuncMode() method to automatically set position to left and top margin after header function is called. Backward compatibility is preserved. This addresses issue #174.
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/fpdf.go b/fpdf.go
index 4afdb8c..0e7071f 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -350,6 +350,15 @@ func (f *Fpdf) SetFontLoader(loader FontLoader) {
f.fontLoader = loader
}
+// SetHeaderFuncMode sets the function that lets the application render the
+// page header. See SetHeaderFunc() for more details. The value for homeMode
+// should be set to true to have the current position set to the left and top
+// margin after the header function is called.
+func (f *Fpdf) SetHeaderFuncMode(fnc func(), homeMode bool) {
+ f.headerFnc = fnc
+ f.headerHomeMode = homeMode
+}
+
// SetHeaderFunc sets the function that lets the application render the page
// header. The specified function is automatically called by AddPage() and
// should not be called directly by the application. The implementation in Fpdf
@@ -676,6 +685,9 @@ func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType) {
f.inHeader = true
f.headerFnc()
f.inHeader = false
+ if f.headerHomeMode {
+ f.SetHomeXY()
+ }
}
// Restore line width
if f.lineWidth != lw {
@@ -2702,6 +2714,13 @@ func (f *Fpdf) SetY(y float64) {
}
}
+// SetHomeXY is a convenience method that sets the current position to the left
+// and top margins.
+func (f *Fpdf) SetHomeXY() {
+ f.SetY(f.tMargin)
+ f.SetX(f.lMargin)
+}
+
// SetXY defines the abscissa and ordinate of the current position. If the
// passed values are negative, they are relative respectively to the right and
// bottom of the page.