1👍
As far as I can see,
merger.append(PdfFileReader(file(local, 'rb')))
should be
merger.append(PdfFileReader(open(pdf, 'rb'))
as local
is a file handle that was already closed. But what you really want to do is to open the just written local file whose name is stored in pdf
.
However, I did not try yet.
Source:stackexchange.com