Skip to content

Instantly share code, notes, and snippets.

@jruby
Created April 17, 2009 07:04
Show Gist options
  • Save jruby/96895 to your computer and use it in GitHub Desktop.
Save jruby/96895 to your computer and use it in GitHub Desktop.
~ ➔ gem maven itext itext 1.3.1
Successfully installed itext-1.3.1-java
1 gem installed
~ ➔ cat hello_pdf.rb
require 'rubygems'
require 'itext'
import com.lowagie.text.pdf.PdfWriter
import com.lowagie.text.Document
import com.lowagie.text.Paragraph
file = File.open('Hello.pdf', 'w')
document = Document.new
writer = PdfWriter.get_instance(document, file.to_outputstream)
paragraph = Paragraph.new('Hello iText!')
document.open
document.add(paragraph)
document.close
~ ➔ jruby hello_pdf.rb
~ ➔ file Hello.pdf
Hello.pdf: PDF document, version 1.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment