I want the the table to be displayed in pdf format .
we are using
format.html
format.json{render json: @user}
et
Step one: register PDF type for use in respond_to blocks
# config/mime_types.rb
Mime::Type.register "application/pdf", :pdf
Step two: in your controller respond to PDF format request
respond_to do |format|
format.html
format.json{render json: @user}
format.pdf do
# ...
# here your PDF generating code
# ...
send_data(your_generated_pdf, filename: 'your_filename.pdf', type: 'application/pdf')
end
end
For generating PDF you can use pdfkit with wkthmltopdf, Prawn and some other. Refer to the respective documentations on their usage.