我使用wkhtmltopdf與PHP,它運作良好。 現在,我想添加一些變量從PHP文件到HTML的,但我沒有找到一個解決方案。wkhtmltopdf在html文件中傳遞變量
PHP文件:
<?php
require '/path/vendor/autoload.php';
use mikehaertl\wkhtmlto\Pdf;
$pdf = new Pdf(array(
'no-outline',
'margin-top' => 0,
'margin-right' => 0,
'margin-bottom' => 0,
'margin-left' => 0,
// Default page options
'disable-smart-shrinking',
));
if($_GET['file'] == 'public'){
$pdf = new Pdf('template_public.html');
}else{
$pdf = new Pdf('template_pro.html');
}
$pdf->send();
?>
HTML文件:
<html>
<head>
<title>Generated PDF file</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div>
{title}
</div>
</body>
</html>
我如何可以替換HTML文件的標題{}?
我不確定這會做 –
工作一直忘記params和返回值。否則,爲什麼不呢?好的,現在應該是一個完整的例子。 – overburn
儘管此代碼可能回答此問題,但提供 有關_why_和/或_how_的其他上下文,它將回答 該問題將顯着改善其長期值 的值。請[編輯]你的答案,添加一些解釋。 –