am->getAssetFromURL('http',$coreUrl);
if (!$asset) {
die(); // Matrix will output an error for this, just kill the script
}// End if
if (!$asset->readAccess()) {
die('You do not have permissons to generate a pdf for this page');
}// End if
}
// Do a url check against the micor site
$domain = array_shift(explode('/',$coreUrl));
if (!in_array( $domain, $allowed_urls )) {
die("The supplied URL is not valid.");
}// End if
// Run wkhtmltopdf to create a temporary file
$path = dirname(__FILE__) . "/tmp_" . time() . ".pdf";
$command = WKHTMLTOPDF_BIN . " $safeUrl $path";
if (!is_file(WKHTMLTOPDF_BIN)) {
die('The utility "wkhtmltopdf" may not been installed on this server. http://code.google.com/p/wkhtmltopdf');
}// End if
exec($command);
if (!is_file($path)) {
die(time() . ' ERROR: Failed to generate PDF for this page');
}// End if
$content = file_get_contents($path);
header('Content-Type: application/pdf');
header('Content-Length: ' . strlen($content));
header('Content-Disposition: inline; filename="' . $name . '.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
// Remove the temporary file
unlink($path);
die($content);
?>