Prawn formulary generation

6 views
Skip to first unread message

Pettor

unread,
Dec 8, 2009, 2:33:54 PM12/8/09
to Prawn
Hi,

Iam a developer using Ruby on Rails to develop a system from a
customer to register interviews using ceratin formularies. Now my
customer has decided they will need PDF generation of these
formularies and i need to know if Prawn has the features needed to
actually generate the correct PDF's.

The formularies is made with HTML + CSS and a section of a formulary
(there are many formularies and sections) can look like:

http://s40.photobucket.com/albums/e212/Pettor/?action=view&current=section_overview.png

The picure shows a section where there are many different questions
with an input field to answer the question. The first part of the
section is a couple of normal questions divided into two columns. Next
part is a matrixquestion that need to fit the hole page (table is used
here) and the last part is the first part copied. So this is more or
less how the sections look with different questions in some specified
order.

If i could create the above look in a PDF with Prawn then i can create
any section more or less. The generated PDF should look as close as
possible to the above picture.

Is Prawn powerful enough to generate these PDF without causing to much
trouble? I mean i already have the code to generate the look above, so
it's all about beeing able to create the same layout, not so much
about fetching data or anything.

Thanks for any reply!

Cheers,
Petter Gustavsson

Henrik Nyh

unread,
Dec 8, 2009, 3:04:41 PM12/8/09
to prawn...@googlegroups.com
On Tue, Dec 8, 2009 at 20:33, Pettor <pet...@gmail.com> wrote:
> i need to know if Prawn has the features needed to
> actually generate the correct PDF's.
>
> The formularies is made with HTML + CSS and a section of a formulary
> (there are many formularies and sections) can look like:
>
> http://s40.photobucket.com/albums/e212/Pettor/?action=view&current=section_overview.png

If the forms are intended to be printed, not filled out in Acrobat
Reader, it's definitely possible, though not completely
straightforward.

Prawn doesn't have a lot of advanced high-level layout functionality
currently, but since you can position containing boxes, text,
geometric shapes and images, you can achieve a lot if you're willing
to put in some effort.

Imagine HTML without floats and tables for layout, but with absolute
positioning and knowing the exact pixel dimensions of the viewport,
pixel widths of strings etc. And with the full power of Ruby to make
helper methods. It's kind of like that.

If the forms are to be filled out in Acrobat Reader, Prawn doesn't
really support that currently. See http://github.com/yob/prawn-forms
for a proof-of-concept, though. Perhaps yob would develop it further
if sponsored.

Since you already have HTML and want the look to be very similar, you
may want to look into the HTML-to-PDF libraries out there. I haven't
used any myself.

Since you're Swedish: a colleague and I may do a Prawn presentation on
the next Stockholm Ruby User Group meet-up, though no date has been
set yet: http://rails.se/rails/show/Railstr%C3%A4ff+n%C3%A4stkommande

Daniel Nelson

unread,
Dec 8, 2009, 4:45:46 PM12/8/09
to prawn...@googlegroups.com
You might look into one of the options that generate PDFs from HTML
and CSS. This lets you keep DRY.

I used Prince XML and the Princely plugin for a client project with
great success. It is pricey ($3,800 US one-time fee), but with the
time you would save by keeping DRY, the business might consider it
worthwhile:
http://www.princexml.com/
http://github.com/mbleigh/princely

There is also WickedPDF, which claims to be an open source solution to
the same problem, though I haven't used it:
http://github.com/mileszs/wicked_pdf

Pettor

unread,
Dec 9, 2009, 3:51:54 PM12/9/09
to Prawn
Thanks for your replies.

I will check Prince PDF a little. Wicked PDF can't be used because it
uses X11. That is a performance and security problem for us.

Cheers,
Petter Gustavsson

On 8 Dec, 22:45, Daniel Nelson <dnelso...@gmail.com> wrote:
> You might look into one of the options that generate PDFs from HTML
> and CSS. This lets you keep DRY.
>
> I used Prince XML and the Princely plugin for a client project with
> great success. It is pricey ($3,800 US one-time fee), but with the
> time you would save by keeping DRY, the business might consider it
> worthwhile:http://www.princexml.com/http://github.com/mbleigh/princely

Gregory Brown

unread,
Dec 9, 2009, 3:55:49 PM12/9/09
to prawn...@googlegroups.com
On Wed, Dec 9, 2009 at 3:51 PM, Pettor <pet...@gmail.com> wrote:
> Thanks for your replies.
>
> I will check Prince PDF a little. Wicked PDF can't be used because it
> uses X11. That is a performance and security problem for us.

Is JRuby an option? If so, think about Flying Saucer.

-greg
Reply all
Reply to author
Forward
0 new messages