Old Emmanuel Oga's Weblog (new one is at www.emmanueloga.com)

PDF::Writer versus libharu2

Posted in Uncategorized by emmanueloga on marzo 5, 2008

Exploring two different libraries for pdf generation on ruby I found that they both have the same example (demo.rb) generating the same results (at least to my eyes :). One was the venerable PDF::Writer library, the other libharu2.

Here. Have some benchmarks on demo.rb:

#Rehearsal --------------------------------------------------------------------
#PDF Writer 100 times              18.984000   0.547000  19.531000 ( 19.616000)
#Haru 2 100 times                   0.235000   0.281000   0.516000 (  0.517000)
#PDF Writer saving file 100 times  18.531000   0.391000  18.922000 ( 19.836000)
#Haru2 saving file 100 times        0.250000   0.375000   0.625000 (  0.688000)
#---------------------------------------------------------- total: 39.594000sec
#user     system      total        real
#PDF Writer 100 times              18.500000   0.265000  18.765000 ( 18.866000)
#Haru 2 100 times                   0.156000   0.344000   0.500000 (  0.500000)
#PDF Writer saving file 100 times  18.703000   0.203000  18.906000 ( 19.336000)
#Haru2 saving file 100 times        0.172000   0.407000   0.579000 (  0.657000)

In this microbenchmark, libharu2 is almost 40 times faster than PDF::Writer !!! Because I think that libharu2 is very useful,  I packaged it as a gem on rubyforge. Try it:

sudo gem install hpdf

Don’t forget to require ‘rubygems’ on your programs before requiring hpdf 🙂

HPDF TODO: Documentation, helpers (for example: no table drawer yet). I have only packaged the gem, didn’t add anything to it.

Tagged with:

3 comentarios

Subscribe to comments with RSS.

  1. Bobbi said, on julio 23, 2008 at 5:58 pm

    Is possible to use haru in Ruport pdf formatter instead of pdf_writer?

  2. emmanueloga said, on julio 23, 2008 at 6:04 pm

    Sorry Bobbi, not currently. Moreover, Gregory Brown is working on a new pure-ruby pdf library, http://github.com/sandal/prawn/tree/master. Even so, I would like to see more Haru usage in the future. I think the biggest let down right now is that the documentation is a little difficult to read.

  3. Bobbi said, on julio 24, 2008 at 6:06 am

    Thanks a lot!


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s

A %d blogueros les gusta esto: