PHP Email with Dynamic Attachment (PDF or .doc)

Hello all.

I’ve been looking everywhere, including these forums, and have gotten nowhere. So I’ll put the question out there for all to see (and hopefully give some help).

Here’s what happens
At the moment information is taken from the database and displayed on the webpage in the form of a certificate. Nothing complicated - the only dynamic content is the users name and date which is taken from their session.

Now, the user has two options - 1) to print out the webpage and certificate, or 2) to email the certificate to themselves to print out later. The trouble is, with either option you get the ugly headers and footers giving innecessary details about the webpage / email in question.

**Here’s what I’d like to happen
**Rather than having the certificate in the email and users printing off the certificate through Outlook, I’d like to send the certificate as either an attached .pdf or .doc format, primarily to get rid of the headers and footers associated with the other mediums, and to also print the full page and not having dodgy margins.

Firstly, I’m unsure how to actually create the document that’s to be sent as an attachment, but secondly how would make this a dynamic file? As there will be more than one user on the site (obviously with different names!) I’ll need the attached file to reflect this and display the correct details.

I know it sounds complicated so I appreciate all the help I get with this. =)