diff --git a/docs/getting_started.coffee.md b/docs/getting_started.coffee.md index bf277d4..f67ee0f 100644 --- a/docs/getting_started.coffee.md +++ b/docs/getting_started.coffee.md @@ -85,6 +85,11 @@ quite simple! doc.addPage() +To add some content every time a page is created, either by calling `addPage()` or automatically, you can use the `pageAdded` event. + + doc.on 'pageAdded', -> + doc.text "Page Title" + You can also set some options for the page, such as it's size and orientation. The `layout` property can be either `portrait` (the default) or `landscape`. diff --git a/lib/document.coffee b/lib/document.coffee index b9dff02..7cb67de 100644 --- a/lib/document.coffee +++ b/lib/document.coffee @@ -99,6 +99,8 @@ class PDFDocument extends stream.Readable # the top left rather than the bottom left @_ctm = [1, 0, 0, 1, 0, 0] @transform 1, 0, 0, -1, 0, @page.height + + @emit('pageAdded') return this