librelist archives

« back to archive

HTML to PDF via PDFKit

HTML to PDF via PDFKit

From:
Kc Erb
Date:
2013-09-24 @ 16:22
Hi all,

In my program, users send out emails with html imbedded. I'm making a
feature which saves a pdf copy of the email in case the recipient turns out
to have an invalid email address.

The easiest way to do this is to directly convert the html into a pdf with
a gem. Luckily such a gem exists: pdfkit <https://github.com/pdfkit/PDFKit>.

Unfortunately pdfkit uses an external shell utility called
wkhtmltopdf<https://code.google.com/p/wkhtmltopdf/>.
Everything works fine on my computer, but when it comes time to package up
my app I'll bet Shoes doesn't know to grab this utility, much less how to
install it on the user's computer.

Any ideas?

-KC


 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."

Re: [shoes] HTML to PDF via PDFKit

From:
Eric Watson
Date:
2013-09-24 @ 21:46
You're right, that'll be a problem. Try Prawn

http://prawn.majesticseacreature.com/

Prawn is pretty low level, so you'll have to tell it how the PDF should 
look, instead of just piping in HTML and getting a spiffy PDF right back. 
I haven't tried it with Shoes, but I've used it in other projects. Works 
great!

Eric

> On Sep 24, 2013, at 11:22, KC Erb <iamkcerb@gmail.com> wrote:
> 
> Hi all,
> 
> In my program, users send out emails with html imbedded. I'm making a 
feature which saves a pdf copy of the email in case the recipient turns 
out to have an invalid email address.
> 
> The easiest way to do this is to directly convert the html into a pdf 
with a gem. Luckily such a gem exists: pdfkit.
> 
> Unfortunately pdfkit uses an external shell utility called wkhtmltopdf. 
Everything works fine on my computer, but when it comes time to package up
my app I'll bet Shoes doesn't know to grab this utility, much less how to 
install it on the user's computer.
> 
> Any ideas?
> 
> -KC
> 
>  
>  "If there is an exception to every rule, then every rule must have at 
least one exception; the exception to this one being that it has no 
exception."

Re: [shoes] HTML to PDF via PDFKit

From:
Kc Erb
Date:
2013-09-24 @ 21:51
On the plus side I've been using prawn in shoes and it works great. On the
downside I was hoping not to have to write the same thing twice, but that's
OK. I'll resign myself to it :)

Thanks Eric!


On Tue, Sep 24, 2013 at 3:46 PM, Eric Watson <wasnotrice@gmail.com> wrote:

> You're right, that'll be a problem. Try Prawn
>
> http://prawn.majesticseacreature.com/
>
> Prawn is pretty low level, so you'll have to tell it how the PDF should
> look, instead of just piping in HTML and getting a spiffy PDF right back. I
> haven't tried it with Shoes, but I've used it in other projects. Works
> great!
>
> Eric
>
> On Sep 24, 2013, at 11:22, KC Erb <iamkcerb@gmail.com> wrote:
>
> Hi all,
>
> In my program, users send out emails with html imbedded. I'm making a
> feature which saves a pdf copy of the email in case the recipient turns out
> to have an invalid email address.
>
> The easiest way to do this is to directly convert the html into a pdf with
> a gem. Luckily such a gem exists: pdfkit<https://github.com/pdfkit/PDFKit>
> .
>
> Unfortunately pdfkit uses an external shell utility called 
wkhtmltopdf<https://code.google.com/p/wkhtmltopdf/>.
> Everything works fine on my computer, but when it comes time to package up
> my app I'll bet Shoes doesn't know to grab this utility, much less how to
> install it on the user's computer.
>
> Any ideas?
>
> -KC
>
>
>  "If there is an exception to every rule, then every rule must have at
> least one exception; the exception to this one being that it has no
> exception."
>
>


-- 
 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."