开发者

Convert multiple doc types (xls, doc, gif, png) to pdf in ruby

I am looking for a way to do this within a ruby on rails app. Need to do this locally within my service as the data is sensitive, I cant use exter开发者_如何学Cnal web services to do this.

Most important is images of various types as this is what most people scan documents into.


Install LibreOffice and Unoconv in your server and run the command.

unoconv -f pdf File.doc

If you want to perform it with only LibreOffice use,

./soffice --headless --convert-to pdf destination_path source_file_path/*.doc


Have you looked at Prawn?

EDIT

There doesn't appear to be a single solution to this problem. There are related StackOverflow questions, though, that might be of some help. For instance:

  • Is it possible to convert an HTML document to Excel with multiple Worksheets/tabs?, for instance, talks about using POI to generate Excel spreadsheets and using the Excel gem to read them.
  • Convert a .doc or .pdf to an image and display a thumbnail in Ruby? discusses using RMagick to convert a PDF to an image.


There now is a single solution to the problem. I work on the PDF Converter Services, so consider me biased, but I have recently written a blog post about how to convert common file types such as DOC, XLS, PPT, HTML etc to PDF (and many other file types) using Ruby. For details see this post.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜