Add gems:-
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
Run bundle install
In Controller:-
def generate_pdf
html = render_to_string(:action => :pdf_file, :layout => false)
pdf = WickedPdf.new.pdf_from_string(html)
save_path = Rails.root.join('public','users.pdf')
File.open(save_path, 'wb') do |file|
file << pdf
end
@mail = ReminderMailer.share_email(params).deliver
flash[:notice] = 'Email sent successfully.'
render 'show', layout: 'simple' if !mobile_device?
end
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
Run bundle install
In Controller:-
def generate_pdf
html = render_to_string(:action => :pdf_file, :layout => false)
pdf = WickedPdf.new.pdf_from_string(html)
save_path = Rails.root.join('public','users.pdf')
File.open(save_path, 'wb') do |file|
file << pdf
end
@mail = ReminderMailer.share_email(params).deliver
flash[:notice] = 'Email sent successfully.'
render 'show', layout: 'simple' if !mobile_device?
end
No comments:
Post a Comment