I'm working on a small project that is supposed to send out a certificate via a pdf. The way its supposed to work is that, the client goes to his admin page and fills out certain information like name/age/date/email etc and thereafter, once Submit is hit its supposed to fill out a PDF(with dompdf) and send it via email.
I'm getting stuck in the part where the PDF is generated.
If i stick to normal text the pdf is generated just fine. As soon as i start to use inline php it freezes after 30 seconds. I found it weird because I've cut the whole document down to literally one long sentence with small string vars and after cutting it down, it now shows the pdf but it comes out blank.
Here is a truncated piece of what i have so far.
HTML: on this page i have a test link like so:
Click this link <a href="certificate-proc.php?loc=florida&name=Lopan&courseMan=mike%20bitz">HERE</a> to send over details to fill into the certificate.
CODE: On the page that receives this information, i have this which is supposed to get the GET info from the link, and pass it to the document.
<?php
require_once('dompdf_config.inc.php');
$locs = $_GET["loc"];
$name = $_GET["name"];
$course = $_GET["courseMan"];
$date = "sunday at some time today it will happen";
//create new dompdf object
$html = ' <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<div id="mainW">
<?php echo $name; ?>
</div><!-- mainW ender -->
</body>
</html> ' ;
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
Right now as it stands, with the above, its supposed to show the name. Although the PDF is generated, nothing prints inside it. Its blank. If i take out the php and add regular text. it works.
Any ideas as to what im missing? im new to all this so any help or direction is greatly appreciated.
Thanks in advanced.
You are using <?php ?>
tags within your string. Try this:
$html = '... <div id="mainW">'.$name.'</div>' ...;
Alternatively, you could add it like so:
$html = '...';
$html .= $name;
$html .= '...';
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments