How to merge pdf files and offer download


Thank you the support for multiple file upload.

How do you combine those uploaded (pdf) files into one and offer a download button?


I tried one solution using pypdf2:

If you need more advanced features check out reportlab

Happy Streamliting, Cheers :balloon:

1 Like

Thank you, exactly what I was looking for.

Where’s the code at?


Got to merge the uploaded documents by:

def merge_pdf (pdfFiles):
    merger = PdfFileMerger()
    for file in pdfFiles: 
        merger.append(file, 'rb')
    _byteIo = BytesIO()
    return _byteIo
st.download_button("Download PDF", data=merged, file_name="merged.pdf",mime='application/octet-stream')

Unless there are other ways?

Thank you!

For any streamlit cloud app you should be able to use the hamburger menu on the top right then “View app source”


1 Like