Export PDFs in a Ruby on Rails project

Generate the content as a PDF

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
bundle install
respond block inside the show method
html = render_to_string template: "PDF template file"
pdf template under view
pdf = WickedPdf.new.pdf_from_string(html)

Handle the PDF generation as a background job

rails generate job pdfs_generate
gem 'delayed_job_active_record'

--

--

Developer ❤️ JS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store