//DEVGURU

Archives: November, 2009

How to convert doc/xls/ppt/… to pdf in Unix console

Wednesday, November 18th, 2009

Today we needed to make a tool to convert Microsoft Office (and preferably other formats) documents to PDF from a Rails application. We have come up with such solution – install OpenOffice.org, CUPS and CUPS-PDF (virtual PDF printer for CUPS) and run it like this:

soffice -headless -pt Cups-PDF file.doc

This command executes OpenOffice.org in so-called ‘headless’ mode – meaning that it will not run anything graphical. It reads the file.doc, and prints it using CUPS-PDF virtual printer. The resulting PDF can be found (by default) in ~/PDF directory.

Validating email in rails

Tuesday, November 17th, 2009

That’s pretty basic stuff but if you wonder how to validate email in rails check out this plugin:

http://github.com/dancroak/validates_email_format_of/

Good luck.