In the app - I need to create a whole bunch of pdfs and then glue them all together. Having installed iText and RJB seems sensible to try and get it to work.
Playing in the console - the following actually worked
>> require 'rjb'
=> ["RjbConf"]
>> Rjb::load('/var/www/html/renaissance/lib/iText.jar')
=> nil
>> filestream = Rjb::import('java.io.FileOutputStream')
=> #
>> pdfreader = Rjb::import('com.itextpdf.text.pdf.PdfReader')
=> #
>> pdfwriter = Rjb::import('com.itextpdf.text.pdf.PdfWriter')
(irb):5: warning: already initialized constant NAME
=> #
>> pdfdocument = Rjb::import('com.itextpdf.text.Document')
=> #
>> document = pdfdocument.new
=> #<#
>> pdfwriter.getInstance(document, filestream.new('/tmp/test.pdf'))
=> #<#
>> document.open
=> nil
>> pdfParagraph = Rjb::import('com.itextpdf.text.Paragraph')
=> #
>> paragraph = pdfParagraph.new("hello world")
=> #<#
>> document.add(paragraph)
=> true
>> document.close
=> nil
>>
It opens a for real pdf with the iconic words "Hello World". Hurrah
No comments:
Post a Comment