AMV, You have inspired me to run envelopes for our statements from our site, here is the code I came up with, hope it helps.
///////////////////////////////
//FILE 1 autopdf_mail.php
<?php
$filename = "$siteurl/create_mail.php";
$options = "--left 0 --right 0 --top 0 --bottom 5";
Write the content type to the client...
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"$month - Invoices.pdf\"");
flush();
# Run HTMLDOC to provide the PDF file to the user...
passthru("htmldoc -t pdf --jpeg --webpage $options '$filename'");
?>
//////////////////////////////
//FILE 2 create_mail.php
<?php
print "<!-- MEDIA LANDSCAPE YES -->";
print "<!-- MEDIA SIZE 4.125x9.5in -->";
print "<!-- FOOTER RIGHT \"\" -->";
include("./snippets/priceformat.php");
include("./includes/common.php");
$getcities =mysql_query("SELECT * FROM tbl_City");
while ($a_row =mysql_fetch_array($getcities))
{
$citynum = $a_row[id];
$city = strtoupper($a_row[city]);
print "<Table align=center height=65%>";
print "<tr><td valign=bottom><img src=\"./images/spacer.gif\" width=120></td><td valign=bottom>";
print " CITY OF $city<BR>
Attention: $a_row[fcfname] $a_row[fclname]<BR>
$a_row[fcmailaddress]<BR>
$a_row[fcmailcity], $a_row[fcmailstate] $a_row[fcmailzip]";
print "</td></tr></table>";
print "<!-- PAGE BREAK -->";
}
?>
The HTML comments are acutally statements to the HTMLDOC program, they set the paper orientation, the paper size (our envelope size is there now), and the blank footer right just takes the pdf page numbers out. Also the Page break comment at the bottom makes it so each time it goes through the loop, it starts on a blank page, so each city gets printed on a seperate evelope.
I'm here if you have questions.
JAKE