I trying to accomplish the following:
I created a one-page site using the method in this post for a company document.
Now I'd like to use the mPDF library to output a PDF document of this page using '@media print {}' styles to style an actual document, TOC etc.
My idea was to create a separate template for this and a separate page, so you could create the PDF by going to this page.
I tried multiple things, like:
Code: Select all
{php}
ini_set("memory_limit","64M");
include("/path/to/mpdf/mpdf.php");
$mpdf=new mPDF('');
$html = '{/php}{menu template="scrollinhoud"}{php}';
';
$mpdf->h2toc = array('H3'=>0, 'H4'=>1);
$mpdf->h2bookmarks = array('H3'=>0, 'H4'=>1);
$mpdf->open_layer_pane = false;
$mpdf->layerDetails[1]['state']='hidden'; // Set initial state of layer - "hidden" or nothing
$mpdf->layerDetails[1]['name']='Correct Answers';
$mpdf->layerDetails[2]['state']='hidden'; // Set initial state of layer - "hidden" or nothing
$mpdf->layerDetails[2]['name']='Wrong Answers';
//==============================================================
if ($_REQUEST['html']) { echo $html; exit; }
if ($_REQUEST['source']) {
$file = __FILE__;
header("Content-Type: text/plain");
header("Content-Length: ". filesize($file));
header("Content-Disposition: attachment; filename='".$file."'");
readfile($file);
exit;
}
//==============================================================
$mpdf->WriteHTML($html);
// OUTPUT
$mpdf->Output(); exit;
//==============================================================
//==============================================================
//==============================================================
//==============================================================
{/php}
I also tried creating a UDT, but saving a template that contains this UDT will cause it to run and create an empty PDF.
Problem is, I have to do this from somewhere within the system, since the content is also all secured content by the FrontEndUsers module. So creating a separate file and calling that will give me a PDF of the login form, even when I'm logged in as a user.