summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorAloidev <aloiweb@gmail.com>2017-07-19 11:00:59 +0700
committerAloidev <aloiweb@gmail.com>2017-07-19 11:00:59 +0700
commitfdeef9c676bdb5f738d02c770b6312c0e2e12775 (patch)
tree7ed0d42f18b2049813697938d1bad29cf8f06312 /fpdf.go
parent1ea782459766b89293454ef7824f1bb5b071c4a1 (diff)
Issue #121 Add Last Page information FooterFnc
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/fpdf.go b/fpdf.go
index 9587e55..2c7e993 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -366,10 +366,17 @@ func (f *Fpdf) SetHeaderFunc(fnc func()) {
// access to the Fpdf instance and other document generation variables.
//
// This method is demonstrated in the example for AddPage().
+// Deprecated: Use SetFooterFuncLpi instead.
func (f *Fpdf) SetFooterFunc(fnc func()) {
f.footerFnc = fnc
}
+// 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)) {
+ f.footerFncLpi = fnc
+}
+
// SetTopMargin defines the top margin. The method can be called before
// creating the first page.
func (f *Fpdf) SetTopMargin(margin float64) {
@@ -538,11 +545,19 @@ func (f *Fpdf) Close() {
}
}
// Page footer
- if f.footerFnc != nil {
+ if f.footerFnc != nil && f.footerFncLpi == nil {
f.inFooter = true
f.footerFnc()
f.inFooter = false
}
+
+ // Page footer
+ if f.footerFncLpi != nil {
+ f.inFooter = true
+ f.footerFncLpi(true) // Last Page.
+ f.inFooter = false
+ }
+
// Close page
f.endpage()
// Close document
@@ -592,11 +607,17 @@ func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType) {
tc := f.color.text
cf := f.colorFlag
if f.page > 0 {
- // Page footer
- if f.footerFnc != nil {
+ // Page footer avoid double call on footer.
+ if f.footerFnc != nil && f.footerFncLpi == nil {
f.inFooter = true
f.footerFnc()
f.inFooter = false
+
+ }
+ if f.footerFncLpi != nil {
+ f.inFooter = true
+ f.footerFncLpi(false) //not last page.
+ f.inFooter = false
}
// Close page
f.endpage()