How to Send Itext Generated PDF to Browser?

I am still attempting to figure out how to send an Itext generated pdf Document to the browser.

I am looking at the following blog posting where someone is using jruby and iText to create a pdf file and then sending it to the browser : http://codersifu.blogspot.com/2007/06/howto-generate-pdf-files-in-ruby-on.html

Unlike the above example I am using only ruby / on rails.

I would like to do precisely this in ROR and I can get to the second last line of the above blog (that is I can generate the document and even the toByteArray or byte ). As in the example:

    document.close // <<<--- I can get this document     send_data String.from_java_bytes(m.toByteArray),          :type=> "application/pdf", :dispostion=>"inline" // I can call the toByteArray and get the array of bytes byte

but I dont know how to send_data to the browser with the document and byetarraystream available.

I try to do a byte.toString() and send that to send_data but when I get byte.toString() from the java classes I get an error :

No Class DefFoundError (org/bouncycastle/asn1/ASN1OctetString)

Where to go from here?

From the blog : Is there an equivalent to String.from_java_bytes in ruby?