mPDF results from PHP with variables

Cannot seem to get this to work, everything from the buffer is showing but no PDF generated, if its all in the php as $html = 'Hello World' it generates fine?

<?php 
include $_SERVER['DOCUMENT_ROOT'].'/TestCert/mpdf/mpdf.php';
ob_implicit_flush();
ob_start(); 
$w = "World";
?>

<html>
<head></head>
<body>

<form method="post"><input type="submit" value="Generate pdf"/>
    <h1>Hello <?php echo $w; ?></h1>
    <a href="" class="button">Generate pdf</a>
</form>
</body>
</html>


<?php
$tableVar = ob_get_contents(); 
if( 'POST' === $_SERVER['REQUEST_METHOD'] )
{
$mpdf=new mPDF('c');
$mpdf->WriteHTML($tableVar);
$mpdf->Output('test.pdf','F');
}
?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s