'Writes all data that has been merged to the given output file.
:param fileobj: Output file. Can be a filename or any kind of
file-like object.'

def write(self, fileobj):

    my_file = False
    if isString(fileobj):
        fileobj = file(fileobj, 'wb')
        my_file = True
    for page in self.pages:
        self.output.addPage(page.pagedata)
        page.out_pagedata = self.output.getReference(self.output._pages.getObject()['/Kids'][(-1)].getObject())
    self._write_dests()
    self._write_bookmarks()
    self.output.write(fileobj)
    if my_file:
        fileobj.close()
