Save pdf to file using template

I can create and save a pdf file with:

pdf =
pdf.select_font “Times-Roman”
pdf.text “Sample PDF Document”, :font_size => 32, :justification =>

but I’d like to re-use rpdf template, i I use the following code:

pdf_content = render_to_string(:template =>
“documents/#{template}-#{kind}”, :layout => false)
send_data(pdf_content, :filename => “#{@document.name_for_file}.pdf”,
:type => ‘application/pdf’, :status => 200)

I have the error “Can only render or redirect once per action”.
How can I save pdf to server disk without render twice ?

kind regards,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs