Skip to content

Commit

Permalink
PageBreak drawable implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
llonchj committed Feb 12, 2018
1 parent 91660d8 commit 40f3640
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pdf/creator/chapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (chap *Chapter) Add(d Drawable) error {
case *Chapter:
common.Log.Debug("Error: Cannot add chapter to a chapter")
return errors.New("Type check error")
case *Paragraph, *Image, *Block, *Subchapter, *Table:
case *Paragraph, *Image, *Block, *Subchapter, *Table, *PageBreak:
chap.contents = append(chap.contents, d)
default:
common.Log.Debug("Unsupported: %T", d)
Expand Down
19 changes: 19 additions & 0 deletions pdf/creator/pagebreak.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package creator

// PageBreak represents a page break for a chapter.
type PageBreak struct {
}

// NewPageBreak create a new page break.
func NewPageBreak() *PageBreak {
return &PageBreak{}
}

// GeneratePageBlocks generates a page break block.
func (p *PageBreak) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) {
blocks := []*Block{
NewBlock(ctx.Width, ctx.PageHeight),
}
ctx.Y = ctx.PageHeight
return blocks, ctx, nil
}

0 comments on commit 40f3640

Please sign in to comment.