summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2019-04-09 10:10:03 -0400
committerKurt <kurt.w.jung@gmail.com>2019-04-09 10:10:03 -0400
commit83024250a9829a15db59ff414a36984300c98771 (patch)
treec19ea55a3a02ef3efc8a832f9dd2307a2bc096ea /fpdf.go
parent24315acbbda57c4f6b80c8441fd108087dd7e305 (diff)
Add PageCount() method
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/fpdf.go b/fpdf.go
index 2c6d7c1..adc510b 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -385,13 +385,20 @@ func (f *Fpdf) SetPageBox(t string, x, y, wd, ht float64) {
}
// SetPage sets the current page to that of a valid page in the PDF document.
-// The SetPage() example demonstrates this method.
+// pageNum is one-based. The SetPage() example demonstrates this method.
func (f *Fpdf) SetPage(pageNum int) {
if (pageNum > 0) && (pageNum < len(f.pages)) {
f.page = pageNum
}
}
+// PageCount returns the number of pages currently in the document. Since page
+// numbers in gofpdf are one-based, the page count is the same as the page
+// number of the current last page.
+func (f *Fpdf) PageCount() int {
+ return len(f.pages) - 1
+}
+
// SetFontLocation sets the location in the file system of the font and font
// definition files.
func (f *Fpdf) SetFontLocation(fontDirStr string) {