Pages

Sponsorship

40% off your First Order with GoDaddy.com!

Dec 16, 2009

Ruby: Write A PDF File Using Ruby


Using the open source PDF::Writer library for Ruby to create PDF documents on the fly and save them on the server.

require "rubygems"
# Get PDF::Writer from http://ruby-pdf.rubyforge.org/pdf-writer/
require "pdf/writer"
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.text "Hello World, Hello, Ruby, Hello PDF.", :font_size => 52, :justification => :center
pdf.save_as("HelloWorld.pdf")
view raw write_pdf.rb hosted with ❤ by GitHub

No comments:

Post a Comment