# Generating views in pdf, rtf, or doc format

**URL:** <https://www.ruby-forum.com/t/generating-views-in-pdf-rtf-or-doc-format/181661>\
**Category:** Rails\
**Created:** [January 15, 2010, 3:14pm UTC](https://www.ruby-forum.com/t/generating-views-in-pdf-rtf-or-doc-format/181661 "2010-01-15T15:14:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b782af/32.png) [@parki](https://www.ruby-forum.com/u/parki)\
**Post date:** [January 15, 2010, 3:14pm UTC](https://www.ruby-forum.com/t/generating-views-in-pdf-rtf-or-doc-format/181661/1 "2010-01-15T15:14:54Z")

</div>

I have a requirement to generate views (list and show views, including  
data and uploaded images) into a format that can be saved and/or  
emailed. I’m looking for opinions on the easiest way to achieve this.  
I’ve researched the use of both PDF::Writer and Prawn, and it seems that  
to re-generate my views in pdf format will require a lot of work. Is  
there an easier way using .rtf or .doc files? The customer does not  
have a preference, they just want the ability save/send hard-copies.

Thanks,  
Brian

---

<div class="post-metadata">

**Author:** ![parki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b782af/32.png) [@parki](https://www.ruby-forum.com/u/parki)\
**Post date:** [January 15, 2010, 3:23pm UTC](https://www.ruby-forum.com/t/generating-views-in-pdf-rtf-or-doc-format/181661/2 "2010-01-15T15:23:18Z")

</div>

Brian P. wrote:

> I have a requirement to generate views (list and show views, including  
> data and uploaded images) into a format that can be saved and/or  
> emailed. I’m looking for opinions on the easiest way to achieve this.

HTML can be saved or e-mailed. So can plain text. What more do you  
need?

> I’ve researched the use of both PDF::Writer and Prawn, and it seems that  
> to re-generate my views in pdf format will require a lot of work. Is  
> there an easier way using .rtf or .doc files? The customer does not  
> have a preference, they just want the ability save/send hard-copies.

Use PDF if HTML is not sufficient. MS Word files have no place on the  
Web or in e-mail since they do not reliably preserve formatting across  
computers, and RTF suffers from the same issues. If you don’t want to  
recreate your views in Prawn markup, then try prawn\_format, Flying  
Saucer, wkhtmltopdf, or Prince, all of which will generate PDF files  
from HTML. .

> Thanks,  
> Brian

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![parki](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b782af/32.png) [@parki](https://www.ruby-forum.com/u/parki)\
**Post date:** [January 15, 2010, 6:44pm UTC](https://www.ruby-forum.com/t/generating-views-in-pdf-rtf-or-doc-format/181661/3 "2010-01-15T18:44:40Z")

</div>

Hi Brian,

I’d definitely recommend going with pdf, and use either princexml  
([Prince - Convert HTML to PDF with CSS](http://www.princexml.com/features/)) or wkhtmltopdf (http://  
[code.google.com/p/wkhtmltopdf/](http://code.google.com/p/wkhtmltopdf/)) to generate pdfs from your app’s html/  
css. You’ll save a ton of time and effort using one of these two  
tools, since you’d be working with the same html (with possibly  
slightly diff css applied for the pdf output) used in your web app ui.

As for which one to choose, … If you (or the client?) can afford  
the princexml license, princexml has greater print-related-css  
implementation coverage than wkhtmltopdf. If you can’t afford or  
don’t want to pay for the license, then go with wkhtmltopdf (and work  
around any of those missing css calls as necessary).

Jeff
