Ruby Project

Still chipping away at Ruby/Rails with my trusty Pickaxe book and thought of an interesting “learn-by-doing” project, though I don’t know if it’s even possible: capture a webpage (containing a completed form) - a snapshot, if you will - as say, a pdf, upon successful submission of said form, then save the file to a folder on the server and attach the file to a confirmation email that gets sent to me and possibly to the sender as well.

Currently I use PHP framework (MAR) to capture the form submission into a relational db, so assuming what I want to do is even possible the above functionality would need to tie into that app. Of course this doesn’t technically need to be done with Ruby, it might even make more sense to do it with PHP since the existing framework is PHP but I’m trying to go the Ruby route and besides, I’m planning to replace the MAR framework with RoR eventually.

Any who, back to the pdf snapshot: doable?

Todd
http://xiiro.com


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I use PrinceXML in my largest project to make PDF out of HTML. That’s a for-pay server-side application, and it’s the cadillac of this problem-space (there’s also a free developer version that adds a subtle watermark to the first page). There are several free HTML->PDF tools out there, have a look at http://ruby-toolbox.com for a listing.

In pure Ruby, you could consume the form submission using Ruby as a CGI language (haven’t done this myself for several years, and I’m not sure where to advise you to turn) and then convert the generated HTML to PDF in a second step. That might be a good learning step for you.

The way I would approach this would be to code the form in Rails, and then make a show.pdf.erb template in the model’s views folder. Add Prince as a gem, or another rendering kit, and you would just get a pdf when you visited example.com/[model_name_plural]/[the id].pdf

Walter

On Jan 27, 2013, at 11:21 PM, Todd wrote:

Still chipping away at Ruby/Rails with my trusty Pickaxe book and thought of an interesting “learn-by-doing” project, though I don’t know if it’s even possible: capture a webpage (containing a completed form) - a snapshot, if you will - as say, a pdf, upon successful submission of said form, then save the file to a folder on the server and attach the file to a confirmation email that gets sent to me and possibly to the sender as well.

Currently I use PHP framework (MAR) to capture the form submission into a relational db, so assuming what I want to do is even possible the above functionality would need to tie into that app. Of course this doesn’t technically need to be done with Ruby, it might even make more sense to do it with PHP since the existing framework is PHP but I’m trying to go the Ruby route and besides, I’m planning to replace the MAR framework with RoR eventually.

Any who, back to the pdf snapshot: doable?

Todd
http://xiiro.com


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walter. Very interesting, PrinceXML. Looks like I have a lot of work ahead of me.

Todd
http://xiiro.com


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Prince is drop-dead easy to use, particularly in Rails, as there’s a gem for it. But even in PHP, it’s just a matter of sending the composed HTML to it, and you get the PDF back. It’s extremely configurable through CSS, and very very forgiving of malformed HTML input (unless you are in XHTML mode). You do need to be root to install it, so those of you on shared servers are going to have to jump through extra hoops (likely involving bribes to the sysops people at your hosting provider) to get to use it.

Walter

On Jan 28, 2013, at 10:38 AM, Todd wrote:

Thanks Walter. Very interesting, PrinceXML. Looks like I have a lot of work ahead of me.

Todd
http://xiiro.com


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Surprisingly it seems the pdf aspect might be the easy (or easier) part, the work for me will be the Ruby programming which, despite my currently very limited understanding, I’m really diggin’ compared to PHP. Not sure why but it seems to make more sense; easier to grasp. Of course ‘easier’ is, for me, a very relative term.

But ouch, the licensing for Prince. Certainly the free watermarked version is fine for my needs but I will take your suggestion and look around the Ruby world for alternative tools. My shared server does seem problematic, though.

Todd

Prince is drop-dead easy to use, particularly in Rails, as there’s a gem for it. But even in PHP, it’s just a matter of sending the composed HTML to it, and you get the PDF back. It’s extremely configurable through CSS, and very very forgiving of malformed HTML input (unless you are in XHTML mode). You do need to be root to install it, so those of you on shared servers are going to have to jump through extra hoops (likely involving bribes to the sysops people at your hosting provider) to get to use it.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You may want to invest in a Linode instance, or try AWS EC2 (free developer version at the latter) to test this out.

Walter

On Jan 28, 2013, at 11:15 AM, Todd wrote:

Surprisingly it seems the pdf aspect might be the easy (or easier) part, the work for me will be the Ruby programming which, despite my currently very limited understanding, I’m really diggin’ compared to PHP. Not sure why but it seems to make more sense; easier to grasp. Of course ‘easier’ is, for me, a very relative term.

But ouch, the licensing for Prince. Certainly the free watermarked version is fine for my needs but I will take your suggestion and look around the Ruby world for alternative tools. My shared server does seem problematic, though.

Todd

Prince is drop-dead easy to use, particularly in Rails, as there’s a gem for it. But even in PHP, it’s just a matter of sending the composed HTML to it, and you get the PDF back. It’s extremely configurable through CSS, and very very forgiving of malformed HTML input (unless you are in XHTML mode). You do need to be root to install it, so those of you on shared servers are going to have to jump through extra hoops (likely involving bribes to the sysops people at your hosting provider) to get to use it.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options