little shorter version:
$margin_right = 72;
$margin_bottom = 72;
$margin_top = 36;
$page_width = 1000;
$page_height = 1294;
$p = PDF_new();
if(!pdf_open_file($p, "")) {
print "error";
exit;
}
PDF_begin_page($p,$page_width,$page_height);
pdf_setrgbcolor_fill($p, 0.63137, 0.47, 0.176);
pdf_rect($p, 0, 0, $page_width , $page_height);
pdf_fill($p);
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
PDF_delete($p);
$len = strlen($buf);
$cd = date("Y_m_d");
$cd = str_replace("_","",$cd);
$fp2 = "testpage.pdf";
$theFile = "../pdf/".$fp2;
// header("Pragma: public");
// header("Expires: 0"); // set expiration time
// header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: ".$len);
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=$fp2");
// header("Content-Transfer-Encoding: binary");
// header("Expires: 0");
$fp = fopen("../pdf/".$fp2, "w+");
fwrite($fp,$buf,$len);
$mail = new htmlMimeMail();
$cemail = "me@me.com";
$mail->setFrom("zzz <postmaster@zzz.com>");
$mail->setSubject("blaah");
$mail->setText("\n.");
$attachment = $mail->getFile($newFILEname);
$mail->addAttachment($attachment,str_replace("pdf","zip",$filename),"application/zip");
$result = $mail->send(array($cemail));
buffer is:
%PDF-1.3 %äãÏÒ 5 0 obj <> stream xœ3Ð3364Q0Ð31†æf Eé\ †@ÂÈÒD¡(•+ žö÷endstream endobj 6 0 obj 45 endobj 4 0 obj <> endobj 7 0 obj <> endobj 3 0 obj <> endobj 1 0 obj <> endobj 2 0 obj <> endobj xref 0 8 0000000000 65535 f 0000000381 00000 n 0000000435 00000 n 0000000289 00000 n 0000000149 00000 n 0000000015 00000 n 0000000131 00000 n 0000000254 00000 n trailer <<7FE73EDC2181613DB629EF3CE04F8C5D>] >> startxref 482 %%EOF
i can't mail this pdf-file ... no idea why... but i tried to zip it and email worked ok but i couldn't open zip file because "unexpected end of file"
if i just open created pdf there is no problem but i can't send it via email. as you can see i have tried many options as header ... result is always same. if i remember right there was some problems with pdf on some php version, this version is 4.3.3 OS is win2k.
any ideas 😕 😕 😕 😕 😕
TIA
-==::T::==-