Emit an event when a page is added

Use the document as the EventEmitter

Update docs
This commit is contained in:
Mathieu Triay 2015-04-07 10:52:58 +01:00
parent a04155fc76
commit fbcb53855e
2 changed files with 7 additions and 0 deletions

View File

@ -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`.

View File

@ -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