Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails Export CSV data to PDF

I have implemented CSV export, and now I am trying to export data to PDF.

How can one export the CSV data from the CSV generated file to PDF.

Thanks.

like image 747
lamrin Avatar asked Jan 17 '26 09:01

lamrin


1 Answers

You can use prawn https://github.com/sandal/prawn to generate pdfs in ruby with some code like:

require 'prawn'
pdf = Prawn::Document.new
pdf.text(my_csv_data)
pdf.render_file('csv.pdf')

There is also a tutorial here: http://railstips.org/blog/archives/2008/10/13/how-to-generate-pdfs-in-rails-with-prawn/

like image 122
Andrew Nesbitt Avatar answered Jan 20 '26 00:01

Andrew Nesbitt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!