     '
          
   end: ->
-    @page.end()
-    
+    @flushPages()
     @_info = @ref()
     for key, val of @info
       if typeof val is 'string'

    # Whether streams should be compressed
    @compress = @options.compress ? yes
    
    # The PDF object store
    @_offsets = []
    @_waiting = 0

    
  addPage: (options = @options) ->
    # end the current page if needed
    @flushPages() unless @options.bufferPages

    # create a page object
    @page = new PDFPage(this, options)
    @_pageBuffer.push(@page)

    # add the page to the object store
    pages = @_root.data.Pages.data
    pages.Kids.push @page.dictionary
