Created
November 15, 2013 19:37
-
-
Save informz/7490324 to your computer and use it in GitHub Desktop.
IText JRuby Integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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