I am trying to generate a PDF from a PHP page. I have the code as below and it works. However, when trying to use the ob_get_clean() as I have seen others do I get a 500 error.
Ideas on other ways I can get the finished generated page? Can Javascript work?
The other issue is that the page requires a login and is also being generated by a POST form so the page can't be easily grabbed.
</html>
<?php
$content = "This will work";//ob_get_clean();
require_once dirname(__FILE__).'/html2pdf/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
//ob_clean();
$html2pdf = new Html2Pdf();
$html2pdf->writeHTML($content);
$html2pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/output.pdf', 'F');
} catch (Html2PdfException $e) {
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}
?>