<?php require("class/fpdf.php");
class PDF extends FPDF { var $B; var $I; var $U; var $HREF;
function PDF($orientation='P',$unit='mm',$format='A4') { //Call parent constructor $this->FPDF($orientation,$unit,$format); //Initialization $this->B=0; $this->I=0; $this->U=0; $this->HREF=''; }
function WriteHTML($html) { //HTML parser $html=str_replace("n",' ',$html); $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); foreach($a as $i=>$e) { if($i%2==0) { //Text if($this->HREF) $this->PutLink($this->HREF,$e); else $this->Write(40,$e); } else { //Tag if($e[0]=='/') $this->CloseTag(strtoupper(substr($e,1))); else { //Extract attributes $a2=explode(' ',$e); $tag=strtoupper(array_shift($a2)); $attr=array(); foreach($a2 as $v) { if(preg_match('/([^=]*)=["']?([^"']*)/',$v,$a3)) $attr[strtoupper($a3[1])]=$a3[2]; } $this->OpenTag($tag,$attr); } } } }
function OpenTag($tag,$attr) { //Opening tag if($tag=='B' || $tag=='I' || $tag=='U') $this->SetStyle($tag,true); if($tag=='A') $this->HREF=$attr['HREF']; if($tag=='BR') $this->Ln(5); }
function CloseTag($tag) { //Closing tag if($tag=='B' || $tag=='I' || $tag=='U') $this->SetStyle($tag,false); if($tag=='A') $this->HREF=''; }
function SetStyle($tag,$enable) { //Modify style and select corresponding font $this->$tag+=($enable ? 1 : -1); $style=''; foreach(array('B','I','U') as $s) { if($this->$s>0) $style.=$s; } $this->SetFont('',$style); }
function PutLink($URL,$txt) { //Put a hyperlink $this->SetTextColor(0,0,255); $this->SetStyle('U',true); $this->Write(40,$txt,$URL); $this->SetStyle('U',false); $this->SetTextColor(0); } }
$html=' U kan met de volgende gegevens inloggen op <a href="http://corderius.overhoorweb.nl">http://corderius.overhoorweb.nl</a> <b>Gebruikersnaam:</b> oostwouderv <b>Wachtwoord:</b> 123123
Eenmaal ingelogd kunt u toetsen toevoegen, bewerken, sluiten, openen of verwijderen en cijfers van leerlingen bekijken. Tevens kunt u daar uw wachtwoord wijzigen.
Met vriendelijke groet,
<b>Lars Groot</b> <i>Hoofd - beheerder overhoorweb.nl</i>';
$pdf = new PDF();
$pdf->AddPage(); $link=$pdf->AddLink(); $pdf->SetLink($link); $pdf->SetFont("Arial","B",29); $pdf->Cell(40,10, "Welkom bij: Corderius Overhoorweb"); $pdf->SetFont("Arial", "", 12); $pdf->SetFontSize(12); $pdf->WriteHTML($html);
// email stuff (change data below) $to = "grootscripting@live.nl"; $from = "info@corderius.overhoorweb.nl"; $subject = "Logingegevens Corderius Overhoorweb"; $message = "<h1>Welkom bij: Corderius Overhoorweb!</h1> In het bijgeleverde PDF document vind u alle informatie omtrent inlog gegevens op het overhoorweb. Het Corderius Overhoorweb is te vinden op: <a href=\"http://corderius.overhoorweb.nl\">http://corderius.overhoorweb.nl</a>
Met vriendelijke groet,
<b>Lars Groot</b> <i>Hoofd - beheerder overhoorweb.nl</i> ";
// a random hash will be necessary to send mixed content $separator = md5(time());
// carriage return type (we use a PHP end of line constant) $eol = PHP_EOL;
// attachment name $filename = "logindata.pdf";
// encode data (puts attachment in proper format) $pdfdoc = $pdf->Output("", "S"); $attachment = chunk_split(base64_encode($pdfdoc));
// main header (multipart mandatory) $headers = "From: ".$from.$eol; $headers .= "MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; $headers .= "Content-Transfer-Encoding: 7bit".$eol; $headers .= "This is a MIME encoded message.".$eol.$eol;
// message $headers .= "--".$separator.$eol; $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol; $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $headers .= $message.$eol.$eol;
// attachment $headers .= "--".$separator.$eol; $headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; $headers .= "Content-Transfer-Encoding: base64".$eol; $headers .= "Content-Disposition: attachment".$eol.$eol; $headers .= $attachment.$eol.$eol; $headers .= "--".$separator."--";
// send message mail($to, $subject, "", $headers);
?>
|