# Rendering pdf

**URL:** <https://www.ruby-forum.com/t/rendering-pdf/169294>\
**Category:** Ruby\
**Created:** [June 2, 2009, 12:16am UTC](https://www.ruby-forum.com/t/rendering-pdf/169294 "2009-06-02T00:16:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![twittwit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@twittwit](https://www.ruby-forum.com/u/twittwit)\
**Post date:** [June 2, 2009, 12:16am UTC](https://www.ruby-forum.com/t/rendering-pdf/169294/1 "2009-06-02T00:16:31Z")

</div>

hello all,

i am new to ruby ( like two hours new! ) but i do know other  
languages. I LOVE RUBY!

anyway, i want to code something to render my website into pdf. i have  
seen these railscasts :

> **[\#153 PDFs with Prawn - RailsCasts](http://railscasts.com/episodes/153-pdfs-with-prawn)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

> **[\#78 Generating PDF Documents - RailsCasts](http://railscasts.com/episodes/78-generating-pdf-documents)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

they are super good but it seems that they are taking the elements and  
reconstruct them into pdf. I wonder is there something that can  
duplicate the webpage as it is ? ( ie, the entire layout will remain  
the same as what is seem the webpage and the only difference is that  
it is no longer html but pdf.)

if not, can someone enlighten me how i should approach this?

thank you all!

bryan

---

<div class="post-metadata">

**Author:** ![twittwit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@twittwit](https://www.ruby-forum.com/u/twittwit)\
**Post date:** [June 2, 2009, 10:17am UTC](https://www.ruby-forum.com/t/rendering-pdf/169294/2 "2009-06-02T10:17:33Z")

</div>

Google “ruby html to pdf” gives these in the first few hits:

[http://sublog.subimage.com/2007/05/29/html-css-to-pdf-using-ruby-on-rails](http://sublog.subimage.com/2007/05/29/html-css-to-pdf-using-ruby-on-rails)  
(prince - commercial)

> **[adsdevshop.com](http://ww38.blog.adsdevshop.com/2007/11/20/easy-pdf-generation-with-ruby-rails-and-htmldoc/)**
>
> This domain may be for sale!

(htmldoc)

[http://jimneath.org/2009/02/16/creating-pdf-documents-in-ruby-on-rails/](http://jimneath.org/2009/02/16/creating-pdf-documents-in-ruby-on-rails/)  
(prince again, but the comments have some other suggestions)

Also, I had a vague idea there were Ruby bindings for at least one of  
the HTML rendering libraries out there - a quick search for “ruby gecko”  
turns up a project, but doesn’t look like it has changed since 2005.

---

<div class="post-metadata">

**Author:** ![twittwit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@twittwit](https://www.ruby-forum.com/u/twittwit)\
**Post date:** [June 2, 2009, 1:03am UTC](https://www.ruby-forum.com/t/rendering-pdf/169294/3 "2009-06-02T01:03:54Z")

</div>

On Mon, Jun 1, 2009 at 6:15 PM, twittwit [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> they are super good but it seems that they are taking the elements and  
> reconstruct them into pdf. I wonder is there something that can  
> duplicate the webpage as it is ? ( ie, the entire layout will remain  
> the same as what is seem the webpage and the only difference is that  
> it is no longer html but pdf.)

If it’s possible to use JRuby, look into FlyingSaucer.

-greg

---

<div class="post-metadata">

**Author:** ![twittwit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@twittwit](https://www.ruby-forum.com/u/twittwit)\
**Post date:** [June 30, 2009, 12:43pm UTC](https://www.ruby-forum.com/t/rendering-pdf/169294/4 "2009-06-30T12:43:56Z")

</div>

I just came across another free (GPL) option for rendering HTML+CSS to  
PDF: [http://www.xhtml2pdf.com/](http://www.xhtml2pdf.com/)

It’s written in Python but apaprently can be invoked via the shell.
