Script/Programming Q: Web form -> Word Merge -> PDF, automated. How?

Sorry for the horrible title, couldn’t think of a way to explain the question in the subject line succinctly.

For a web business that’s in its earliest planning stages, I know we need to have this sort of work flow being done on our server automatically (except for the customer’s part):

  1. Visitors/customers fill in a form with personal details (easy enough for me)
  2. Details get entered into a database (also easy)
  3. Customer pays (again… straightforward)
  4. After payment is confirmed, and using an already set-up MS Word Mail Merge document, these details should be mapped to the corresponding merge fields
  5. The Word document, which could be either a single page document or an ebook, would be converted to PDF and a download link sent to the purchaser by mail.

Oh, and all this needs to be done in real-time, instantly (or within a few moments) so the file is available for download pretty much after sale.

Now, steps 1, 2 and 3 are, as I mention, simple to set up and are within my skill set.

It’s steps 4 and 5 where we move vastly beyond my knowledge. I’m a [del]lover not a fighter[/del] designer not a programmer, and while I can tweak PHP scripts to a degree, I’m no expert in any scripting language, nor am I realy good with MS Word scripts.

I guess what I’m asking is:

a) Is all this possible with a single script, or would a suite of different scripts have to be used?

b) By some miracle, does anyone know of any pre-packaged scripts/programs that perform all of these chores?

c) If neither of the above are true, how difficult do you think the programming would be to create such a bespoke script, and what kinda money would you guesstimate would be feasible for such a coup? Would this be something one could ask of someone at Elance or one of the other hire-a-coder type places?

Right now we’re at the very very very beginning phases of forming this enterprise and I’m just asking around. Ideally we’d have someone create the script (or manipulate existing scripts so they do the job right) and even hire the person as a tech. But I’m not sure if we’re asking too much while not being able to pay huge amounts. So I ask here, hoping someone has enough knowledge of what might be necessary or even feasible in creating such a relatively seamless (to the customer) work flow.

Whew. Anyone? Did I make any sense while explaining this? Any recommendations would be extraordinarily helpful!

Wouldn’t it be easier to make the PDF, leave a blank space, and then just overlay the customer info directly into the PDF with PHP? (Only because Word isn’t the easiest thing to manipulate with LAMP systems.)

Thanks for the reply, Reply! (You probably get that a lot, sorry.) The problem as far as I can see it/understand it in that thread is that the PDF layout is fairly fixed, but the text will be of varying sizes – names and other personalized details. I’m not sure, at least from what I can gather, that a fixed PHP layout will be flexible enough to manipulate in that way. I could definitely be wrong considering I know so little.

Forgot to mention that ideally we’d be able to create .epub and .mobi versions as well. Hmm. Probably a tall order.

What is the point of the Word document step?

We’ve done a lot of work with checkout -> database -> PDF invoice. It’d be pretty easy to find someone to set that up (you’d have to hook it up to PDF writer software, yes). What’s the need for Word?

Hi ZipperJJ. Word’s necessary because the these are going to be ebooks and other documents that will have to be set up with merge fields. Are you saying that one can set up a preformatted PDF with such merge fields that can be populated from a database?

This may work Best Open Source Mac Software Development Software 2023, but it seems to have not been updated recently.
Or this http://pdf-php.com/

In fact, go to http://freecode.com and search for PDF php to get a list of possibilities, including using Open/LibreOffice as the intermediate.

Personally, I would look at Plone (http://plone.org) but only if you are OK with Python.

Yeah, but you’ll have to roll-your-own code to do the replacement. You can find an XLST to transform a XML file into a PDF. So what you could do is:

  1. Find/write that XLST
  2. Put your fields in the PDF in a way they’re easy to identify (“!!!FIRST_NAME!!!”)
  3. Convert the PDF into an XML (only need to do this once each time you edit the PDF)
  4. Do a simple find/replace to replace !!!FIRST_NAME!!! with the name from the database (this is where most of your code will be)
  5. Use the XLST to convert the XML back into a PDF.

Hey guys, sorry for the delay in responding. Your help has been tremendously valuable. Thanks for the explanation, Blakeyrat. Totally beyond my skill level but now I understand the process better. :slight_smile:

And si_blakely, I’m so grateful for that php-pdf link, as that program does almost exactly what we need it to, and to bridge the gap I’ve even spoken with one of the guys behind it and we’ll probably hire them to do a bit of customization for us. Thank heavens it’s a PHP product since PHP is the one script language I have a passing familiarity with. Not that I’ll need to go under the hood, so to speak, but I always prefer to feel comfortable with a program, at lest enough to look at the code and understand what it’s doing.

Many thanks to everyone for all your help.