summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2017-07-19 08:57:33 -0400
committerKurt <kurt.w.jung@gmail.com>2017-07-19 08:57:33 -0400
commit784ad190acab08c54aa4847f15207d5fa9c25ef0 (patch)
tree0c5bb80595a5fd7936eddb6af939c7f3834ff279 /fpdf.go
parentfdeef9c676bdb5f738d02c770b6312c0e2e12775 (diff)
Tweak some last page expressions and comments
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go47
1 files changed, 24 insertions, 23 deletions
diff --git a/fpdf.go b/fpdf.go
index 2c7e993..a8656dd 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -363,18 +363,27 @@ func (f *Fpdf) SetHeaderFunc(fnc func()) {
// Close() and should not be called directly by the application. The
// implementation in Fpdf is empty, so you have to provide an appropriate
// function if you want page footers. fnc will typically be a closure that has
-// access to the Fpdf instance and other document generation variables.
+// access to the Fpdf instance and other document generation variables. See
+// SetFooterFuncLpi for a similar function that passes a last page indicator.
//
// This method is demonstrated in the example for AddPage().
-// Deprecated: Use SetFooterFuncLpi instead.
func (f *Fpdf) SetFooterFunc(fnc func()) {
f.footerFnc = fnc
+ f.footerFncLpi = nil
}
-// SetFooterFuncLpi work like SetFooterFnc it's just add Last Page information,
-// true mean this is the last page.
-func (f *Fpdf) SetFooterFuncLpi(fnc func(bool)) {
+// SetFooterFuncLpi sets the function that lets the application render the page
+// footer. The specified function is automatically called by AddPage() and
+// Close() and should not be called directly by the application. It is passed a
+// boolean that is true if the last page of the document is being rendered. The
+// implementation in Fpdf is empty, so you have to provide an appropriate
+// function if you want page footers. fnc will typically be a closure that has
+// access to the Fpdf instance and other document generation variables.
+//
+// This method is demonstrated in the example for AddPage().
+func (f *Fpdf) SetFooterFuncLpi(fnc func(lastPage bool)) {
f.footerFncLpi = fnc
+ f.footerFnc = nil
}
// SetTopMargin defines the top margin. The method can be called before
@@ -545,18 +554,13 @@ func (f *Fpdf) Close() {
}
}
// Page footer
- if f.footerFnc != nil && f.footerFncLpi == nil {
- f.inFooter = true
+ f.inFooter = true
+ if f.footerFnc != nil {
f.footerFnc()
- f.inFooter = false
- }
-
- // Page footer
- if f.footerFncLpi != nil {
- f.inFooter = true
- f.footerFncLpi(true) // Last Page.
- f.inFooter = false
+ } else if f.footerFncLpi != nil {
+ f.footerFncLpi(true)
}
+ f.inFooter = false
// Close page
f.endpage()
@@ -607,18 +611,15 @@ func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType) {
tc := f.color.text
cf := f.colorFlag
if f.page > 0 {
+ f.inFooter = true
// Page footer avoid double call on footer.
- if f.footerFnc != nil && f.footerFncLpi == nil {
- f.inFooter = true
+ if f.footerFnc != nil {
f.footerFnc()
- f.inFooter = false
+ } else if f.footerFncLpi != nil {
+ f.footerFncLpi(false) // not last page.
}
- if f.footerFncLpi != nil {
- f.inFooter = true
- f.footerFncLpi(false) //not last page.
- f.inFooter = false
- }
+ f.inFooter = false
// Close page
f.endpage()
}