From 83024250a9829a15db59ff414a36984300c98771 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 9 Apr 2019 10:10:03 -0400 Subject: Add PageCount() method --- fpdf.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'fpdf.go') 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) { -- cgit v1.2.1-24-ge1ad