Skip to content

Instantly share code, notes, and snippets.

@informz
Created November 15, 2013 19:37
Show Gist options
  • Save informz/7490324 to your computer and use it in GitHub Desktop.
Save informz/7490324 to your computer and use it in GitHub Desktop.
IText JRuby Integration
require 'java'
require 'itext'
java_import com.lowagie.text.Document
java_import com.lowagie.text.PageSize
java_import com.lowagie.text.pdf.PdfPCell
java_import com.lowagie.text.pdf.PdfPTable
java_import com.lowagie.text.pdf.PdfWriter
java_import java.lang.String
java_import java.io.FileOutputStream
class PDFDriver
def initialize()
#export CLASSPATH=/usr/local/Cellar/jruby/1.7.5/libexec/lib/ruby/gems/shared/gems/itext-2.0.7-java/lib/iText-2.0.7.jar
end
def makePDF()
doc = Document.new()
stream = FileOutputStream.new("./test.pdf")
PdfWriter.getInstance doc, stream
doc.open()
table = PdfPTable.new(1)
table.addCell("Hello World")
doc.add(table)
doc.close()
end
end
driver = PDFDriver.new()
driver.makePDF()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment