# How to Send Itext Generated PDF to Browser?

**URL:** <https://www.ruby-forum.com/t/how-to-send-itext-generated-pdf-to-browser/142969>\
**Category:** Rails\
**Created:** [July 14, 2008, 3:17am UTC](https://www.ruby-forum.com/t/how-to-send-itext-generated-pdf-to-browser/142969 "2008-07-14T03:17:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [July 14, 2008, 3:17am UTC](https://www.ruby-forum.com/t/how-to-send-itext-generated-pdf-to-browser/142969/1 "2008-07-14T03:17:13Z")

</div>

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](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?
