Export to PDF

Refer the following link :
http://www.artima.com/rubycs/articles/pdf_writer4.html