Create an .rtf version of the document and put in tags that can be replaced like:
My name is {NAME} leaving space for appropriate content. Save it, then use string replace to replace the tags
$row['dateissue'] = date('jS F y');
$row['userid'] = $userid;
$row['datepay'] = $_REQUEST['paydate'];
$row['clickid'] = $_REQUEST['clickid'];
$row['amount'] = $_REQUEST['amount'];
$rtf = file_get_contents('customer-invoice.rtf');
// beautifully lazy system of knocking rtf's break a word up over multiple lines
$rtf = str_replace("\r\n", '', $rtf); // lines are broken /r/n on windows
foreach ($row as $tag => $value)
$rtf = str_replace('\{'.$tag.'\}', $value, $rtf);
header('Content-type: application/rtf');
# replace whatever you want the filename to default to
header("Content-Disposition: attachment; filename=invoice-$row[clickid].rtf");
header('Pragma: no-cache');
header('Expires: 0');
echo $rtf;
exit;
EDIT: Forgot to say, in rtfs line breaks are '\par ' so if you've got multiline content write a nl2par function like [man]nl2br[/man]