I am creating a site where we will be selling an eBook. The eBook is done in Microsoft Word, but can be converted into any document needed - even a PDF first if possible. I would like to have this done with Ruby on Rails too (if possible) - since the site would be done in ROR. If it couldn't be done in ROR - then PHP would be my next best choice.

What I want to do, is after the customer checkout, I want to create their personal version of the eBook in PDF format. That PDF would be password protected (probably just make the password their email address), and I want to have a dynamic field at the bottom of every page (probably in the footer) that says "Licensed to: customer@emailaddress.com." Somewhat like what Sitepoint does.

What would be the best way to do that. I know I can create a dynamic html page with the fields on it and have it converted to a PDF, but how would I have something that is formatted like a book in MS Word (or similar app) converted to a PDF with the watermarks or dynamic fields inserted?

Any ideas? Any good plugins or methods of achieving this?

Thanks in advance for any of you suggestions. I have been learning ROR over the last few weeks and love it so far!