如何制作按钮?如果我现在打开页面,它不会显示html,而是立即转换&下载pdf。我想要一个按钮,使它只转换&当您按下提交按钮时下载。
这是我的密码。
<?php
require_once("dompdf_config.inc.php");
ob_start();
?>
<html>
<body>
<p>Put your html here, or generate it with your favourite templating system.</p>
</body>
</html>
<?php
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
我是这方面的新手,但我想这与有关
<?php
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
部分。我使用Dompdf。
一个选项是创建另一个php文件,该文件将所需内容生成为pdf,并链接到要放置下载选项的php文件。
view.html <- This is the page where your link is at
<a href="pdfGen.php"> convert & download </a>
pdfGen.php
<?php
require_once("dompdf_config.inc.php");
ob_start();
?>
<html>
<body>
<p>Put your html here, or generate it with your favourite templating system.</p>
</body>
</html>
<?php
$html = ob_get_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>