views:

484

answers:

6

I would like to create pdfs with ruby. One special need is embedding a picture into text (or a textblock), which means I need to be able to let the text flow around the image. E.g. the image should be in the rigth upper corner and the text should start left of the image and continue after the image by using the whole width of the page. How can I do this in ruby? Thank you for any suggestions!

+3  A: 

Prawn to the rescue?

Zsolt Botykai
Thank you for your suggestion. I already tried prawn, but unfortunately I was not succesfull. I could not place the image into the text. Do you know how to do it?
Adrian
Prawn is great.
dylanfm
After all, Prawn was the solution for my problem. Together with Prawn-layout and Prawn-format it is possible to place texts and images in a exact way, and textflow arround images is also possible. Thanks for all the suggestions!
Adrian
+1  A: 

I like the html -> pdf approach. Although it is probably not the best option (prawn is) it makes it easy to design the pdf. See this website. You could also go for the approach documented at jimneath.org.

Good luck

Maran
Thank you for your help. Unfortunately I need to create a pdf in print qualitiy. So I guess the html -> pdf approach won't be precise enough to do that.
Adrian
+1  A: 

iText is the heavyweight that will allow you to do anything you want with PDFs you can bridge to it with jRuby.

Another option I used was driving open office (it has a ui less option which you can automate from Ruby)

Sam Saffron
A: 

Although I haven't done it myself I've seen people use a headless Open Office. You can control it from Ruby and use it to generate PDF files. You can even use an Open Office template and just fill in some elements into it.

ujh
+1  A: 

How about having Ruby generate some LaTeX code, then use pdflatex to produce the PDF?

splicer
+3  A: 

In the past to get print quality PDFs in Ruby, I used rtex.

It's fast too, which is a real bonus.

Dan Harper - Leopard CRM