summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck2
-rw-r--r--fpdf.go6
-rw-r--r--fpdf_test.go8
3 files changed, 11 insertions, 5 deletions
diff --git a/check b/check
index 86a5bc6..dcc2519 100755
--- a/check
+++ b/check
@@ -1,3 +1,3 @@
golint .
-go tool vet -all .
+go vet -all .
gofmt -s -l .
diff --git a/fpdf.go b/fpdf.go
index f18f2ad..1199c4f 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -383,7 +383,9 @@ func (f *Fpdf) SetPageBoxRec(t string, pb PageBox) {
func (f *Fpdf) SetPageBox(t string, x, y, wd, ht float64) {
f.SetPageBoxRec(t, PageBox{SizeType{Wd: wd, Ht: ht}, PointType{X: x, Y: y}})
}
+
// SetPage sets the current page to that of a valid page in the PDF document.
+// The SetPage() example demonstrates this method.
func (f *Fpdf) SetPage(pageNum int) {
if (pageNum > 0) && (pageNum < len(f.pages)) {
f.page = pageNum
@@ -677,7 +679,7 @@ func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType) {
return
}
if f.page != len(f.pages)-1 {
- f.page = len(f.pages)-1
+ f.page = len(f.pages) - 1
}
if f.state == 0 {
f.open()
@@ -693,7 +695,7 @@ func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType) {
fc := f.color.fill
tc := f.color.text
cf := f.colorFlag
-
+
if f.page > 0 {
f.inFooter = true
// Page footer avoid double call on footer.
diff --git a/fpdf_test.go b/fpdf_test.go
index 7969f94..3201ef9 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -2384,8 +2384,10 @@ func ExampleFpdf_SubWrite() {
// Successfully generated pdf/Fpdf_SubWrite.pdf
}
-func ExampleChangePage() {
- pdf := gofpdf.New("P", "cm", "A4", "")
+// ExampleFpdf_SetPage demomstrates the SetPage() method, allowing content
+// generation to be deferred until all pages have been added.
+func ExampleFpdf_SetPage() {
+ pdf := gofpdf.New("L", "cm", "A4", "")
pdf.SetFont("Times", "", 12)
var time []float64
@@ -2435,4 +2437,6 @@ func ExampleChangePage() {
fileStr := example.Filename("Fpdf_SetPage")
err := pdf.OutputFileAndClose(fileStr)
example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated pdf/Fpdf_SetPage.pdf
}