Reputation: 145
I would know how generate many PDF with wicked_pdf without reload the page, My function not render a PDF view but it direct download as attachement
In my view the user select a template and download it but if i want change the template and download again i must reload the page
My form in the view:
<%= form_tag preview_path(@document, format: :pdf), method: :get do %>
<%= select_tag "id", options_from_collection_for_select(@templates, "id", "code"), include_blank: true %>
<%= submit_tag "Download" %>
<% end %>
How i respond in my controller:
respond_to do |format|
format.pdf do
render pdf: "Labels " + @template.code,
template: "documents/preview.pdf.erb",
layout: 'layouts/pdf.html.erb',
disposition: 'attachment', /* DIRECT DOWNLOAD */
locals: {:document => @document},
show_as_html: false,
margin: { top: @template.top_margin, # default 10 (mm)
bottom: @template.bottom_margin,
left: @template.left_margin,
right: @template.right_margin },
paper_size: @template.paper_size
end
end
end
Upvotes: 1
Views: 397
Reputation: 765
Looks like you should solve a problem it with another way:
window.open(ajax_result.url);
Upvotes: 1