I have a view of the data of a person (contact data, address, work data, medical data, etc.). At the moment I can convert everything I have in the PDF into PDF, but what I need is that when I press the button to convert to PDF I will see a screen (it can be a modal), where by means of checks I can choose which sections of my view to print.
Currently for printing I use the def show
where I have defined the parameters to convert a file list_pdf.pdf.erb
in pdf
with the data of the view.
I use the gem wicked_pdf
in rails 4
.
[updated]
I have the following ...
controller user
def show
respond_to do |format|
format.html
format.pdf do
render :pdf => "file_name",
end
end
end
# views / user / show.html.erb
<div>
...
<h2><%= @user.last_name %> <%= @user.name %></h2>
...
</div>
#boton activa modal
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#miModal">
#el modal
...
<div class="modal-body">
<%= form_for employee_path do %>
Area 1
<%= check_box_tag :area1 %>
Area 2
<%= check_box_tag :area2 %>
<% end %>
</div>
<div class="modal-footer">
#boton que imprime
<%= link_to user_path( format: :pdf), :target => '_blank', class: 'btn btn-default' do %>
Imprimir <span>
<i class="fa fa-print " aria-hidden="true"></i></span>
<%end%>
</div>
---
show.pdf.erb
...
<% if params[:area1]%>
<div>
..bloque
</div>
<%end%>
in the controller I tried and I can not recover the value of params [: area1]. greetings