Update on PDF Generation and Emailing

Rails

Sick! After 15 minutes of setup and 4 hours of debuging I have the ability to generate,save, and then email a pdf all from a Rails app!

Here are the keys:

1. I’m using PDF::Writer for PDF generation

2. I followed the standard email with attachment setup outlined in Pragmatic’s Rails Recipe eBook.

3. The key is on the file read: file=File.open("#{RAILS_ROOT}/path/to/file.pdf") will result in an empty pdf – well not totally empty – it has all the data, it just won’t display it…shit…now what?

4.After 4 hours of hair loss I decided to  browse the PDF::Writer tutorial and found what does work: file= File.open("#{RAILS_ROOT}/path/to/file.pdf","rb")

Awesome.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s