How to add multiple pdfs to zip file for download in rails -


i have controller action creates pdfs. want able pdfs , save them in zip file user can download.

my controller handles creation of 1 pdf, don't know how

def showpdf     respond_to |format|       format.html       format.pdf         pdf = prawn::document.new(page_size:  "a4",margin: [0,0,0,0])          #pdf creation stuff          send_data pdf.render, filename: 'report.pdf', type: 'application/pdf'       end     end end 

i able change generate multiple pdfs don't know where/how store them before zipping them download...

prawn allows save generated pdf local filesystem, with

pdf.render_file "foo.pdf" 

i make directory in tmp folder (/tmp or rails_root/tmp), build necessary zip files in folder, zip folder (using gem or shell command) , send_data resulting zip file.

i wrap in class method, class of thing having pdf generated it, keep controller clean.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -