M
M
mrruslan2013-12-18 15:23:14
Ruby on Rails
mrruslan, 2013-12-18 15:23:14

What is the best gem to use to generate rtf?

What is the best gem to use to generate rtf? Maybe there are ready-made solutions for converting pdf to rtf, since the necessary information is already generated in pdf, but you also need it in rtf.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Penkovsky, 2013-12-22
@mrruslan

I used
gem "pdfkit", '0.5.1' - for pdf
gem "tidy_ffi" gem 'rtf' - for rtf
both generate from pre-rendered html, for pdf you need pre-installed wkhtmltopdf on the server and you can also include styles

kit = PDFKit.new(html)
    kit.stylesheets << Rails.public_path+"/css/print_doc.css"
    pdf = kit.to_pdf
    send_data pdf, :type => "application/pdf", :filename => "#{title}.pdf"

doc = RTF::Converters::HTML.new(html, :noclean => true)
    rtf = doc.to_rtf
    send_data rtf, :type => "application/rtf", :filename => "#{title}.rtf"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question