Refactor to create new function download_pdf()