diff options
author | Yash Kamothi <yash@avendahealth.com> | 2019-02-27 12:06:52 -0800 |
---|---|---|
committer | Yash Kamothi <yash@avendahealth.com> | 2019-02-27 12:06:52 -0800 |
commit | 6766a7e6d59e243ee86f02ff6646bdbc6464bbd8 (patch) | |
tree | c69d2424368d0d0dbabd837dc09c6a01a76e44ee | |
parent | 567bef933d5649777a8b39772ad57dc9ddaba8d8 (diff) |
added functionality to change the current page in the pdf document
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | def.go | 1 | ||||
-rw-r--r-- | fpdf.go | 10 | ||||
-rw-r--r-- | fpdf_test.go | 6 | ||||
-rw-r--r-- | ttfparser_test.go | 2 |
5 files changed, 16 insertions, 4 deletions
@@ -14,3 +14,4 @@ private *.sublime* *.swp **/*.test +.idea/ @@ -442,6 +442,7 @@ type Pdf interface { SetMargins(left, top, right float64) SetPageBoxRec(t string, pb PageBox) SetPageBox(t string, x, y, wd, ht float64) + SetPage(pageNum int) SetProtection(actionFlag byte, userPassStr, ownerPassStr string) SetRightMargin(margin float64) SetSubject(subjectStr string, isUTF8 bool) @@ -383,6 +383,12 @@ 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. +func (f *Fpdf) SetPage(pageNum int) { + if (pageNum > 0) && (pageNum < len(f.pages)) { + f.page = pageNum + } +} // SetFontLocation sets the location in the file system of the font and font // definition files. @@ -670,6 +676,9 @@ func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType) { if f.err != nil { return } + if f.page != len(f.pages)-1 { + f.page = len(f.pages)-1 + } if f.state == 0 { f.open() } @@ -684,6 +693,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 d84de54..7d862fa 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -32,8 +32,8 @@ import ( "time" "github.com/jung-kurt/gofpdf" - "github.com/jung-kurt/gofpdf/internal/example" - "github.com/jung-kurt/gofpdf/internal/files" + "../gofpdf/internal/example" + "../gofpdf/internal/files" ) func init() { @@ -2381,4 +2381,4 @@ func ExampleFpdf_SubWrite() { example.Summary(err, fileStr) // Output: // Successfully generated pdf/Fpdf_SubWrite.pdf -} +}
\ No newline at end of file diff --git a/ttfparser_test.go b/ttfparser_test.go index 3286db2..5aaf244 100644 --- a/ttfparser_test.go +++ b/ttfparser_test.go @@ -21,7 +21,7 @@ import ( "fmt" "github.com/jung-kurt/gofpdf" - "github.com/jung-kurt/gofpdf/internal/example" + "../gofpdf/internal/example" ) func ExampleTtfParse() { |