diff --git a/pdf/creator/chapters.go b/pdf/creator/chapters.go index b0c86459..9b2e8add 100644 --- a/pdf/creator/chapters.go +++ b/pdf/creator/chapters.go @@ -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) diff --git a/pdf/creator/pagebreak.go b/pdf/creator/pagebreak.go new file mode 100644 index 00000000..6193c40a --- /dev/null +++ b/pdf/creator/pagebreak.go @@ -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 +}