'Merges the pages from the given file into the output file at the
specified page number.
:param int position: The *page number* to insert this file. File will
be inserted after the given number.
:param fileobj: A File Object or an object that supports the standard read
and seek methods similar to a File Object. Could also be a
string representing a path to a PDF file.
:param str bookmark: Optionally, you may specify a bookmark to be applied at
the beginning of the included file by supplying the text of the bookmark.
:param pages: can be a :ref:`Page Range <page-range>` or a ``(start, stop[, step])`` tuple
to merge only the specified range of pages from the source
document into the output document.
:param bool import_bookmarks: You may prevent the source document\'s bookmarks
from being imported by specifying this as ``False``.'

def merge(self, position, fileobj, bookmark=None, pages=None, import_bookmarks=True):

    my_file = False
    decryption_key = None
    if isString(fileobj):
        fileobj = file(fileobj, 'rb')
        my_file = True
    elif isinstance(fileobj, file):
        fileobj.seek(0)
        filecontent = fileobj.read()
        fileobj = StreamIO(filecontent)
        my_file = True
    elif isinstance(fileobj, PdfFileReader):
        orig_tell = fileobj.stream.tell()
        fileobj.stream.seek(0)
        filecontent = StreamIO(fileobj.stream.read())
        fileobj.stream.seek(orig_tell)
        fileobj = filecontent
        if hasattr(fileobj, '_decryption_key'):
            decryption_key = fileobj._decryption_key
        my_file = True
    pdfr = PdfFileReader(fileobj, strict=self.strict)
    if (decryption_key is not None):
        pdfr._decryption_key = decryption_key
    if (pages == None):
        pages = (0, pdfr.getNumPages())
    elif isinstance(pages, PageRange):
        pages = pages.indices(pdfr.getNumPages())
    elif (not isinstance(pages, tuple)):
        raise TypeError('"pages"    must    be    a    tuple    of    (start,    stop[,    step])')
    srcpages = []
    if bookmark:
        bookmark = Bookmark(TextStringObject(bookmark), NumberObject(self.id_count), NameObject('/Fit'))
    outline = []
    if import_bookmarks:
        outline = pdfr.getOutlines()
        outline = self._trim_outline(pdfr, outline, pages)
    if bookmark:
        self.bookmarks += [bookmark, outline]
    else:
        self.bookmarks += outline
    dests = pdfr.namedDestinations
    dests = self._trim_dests(pdfr, dests, pages)
    self.named_dests += dests
    for i in range(*pages):
        pg = pdfr.getPage(i)
        id = self.id_count
        self.id_count += 1
        mp = _MergedPage(pg, pdfr, id)
        srcpages.append(mp)
    self._associate_dests_to_pages(srcpages)
    self._associate_bookmarks_to_pages(srcpages)
    self.pages[position:position] = srcpages
    self.inputs.append((fileobj, pdfr, my_file))
