# A String.from\_java\_bytes Equivalent?

**URL:** <https://www.ruby-forum.com/t/a-string-from-java-bytes-equivalent/142816>\
**Category:** Rails\
**Created:** [July 11, 2008, 7:36pm UTC](https://www.ruby-forum.com/t/a-string-from-java-bytes-equivalent/142816 "2008-07-11T19:36:01Z")\
**Posts on this page:** 2\
**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 11, 2008, 7:36pm UTC](https://www.ruby-forum.com/t/a-string-from-java-bytes-equivalent/142816/1 "2008-07-11T19:36:01Z")

</div>

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)

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 :

```
document.close <<<--- I can get this document and the m

```

bytearraystream  
send\_data String.from\_java\_bytes(m.toByteArray),  
:type=\> “application/pdf”, :dispostion=\>“inline”

## but I dont know how to send\_data to the browser with the document and byetarraystream available.

is there an equivalent to String.from\_java\_bytes in ruby?

---

<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, 5:55pm UTC](https://www.ruby-forum.com/t/a-string-from-java-bytes-equivalent/142816/2 "2008-07-14T17:55:42Z")

</div>

I think I may have figured this out.

to pass data to the send\_data method you just need to send it the  
.toByteArray() output and no need to do a String.from\_java\_bytes!!

So I can bypass the from\_java\_bytes in my case…

Ather S. wrote:

> 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)
> 
> 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 :
> 
> ```
> document.close <<<--- I can get this document and the m
> 
> ```
> 
> bytearraystream  
> send\_data String.from\_java\_bytes(m.toByteArray),  
> :type=\> “application/pdf”, :dispostion=\>“inline”
> 
> ## but I dont know how to send\_data to the browser with the document and byetarraystream available.
> 
> is there an equivalent to String.from\_java\_bytes in ruby?
