Merge pull request #384 from MathieuLoutre/page-added-event

Emit an event when a page is added
This commit is contained in:
Devon Govett 2015-10-25 10:39:33 -07:00
commit 03a45a1354
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