PDF created with Html2pdf and how to save differen

2019-09-21 04:01发布

I am using html2pdf sucessfully created pdf, then I want to save pdf with different name based on the textbox value.

<?php

$diff_name=$_POST['name'];

$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));

// save different name
$html2pdf->Output('$diff_name.pdf', 'F');

?>
<html>
 <body>
  <input type="text" name="name" />
 </body>
</html>

标签: php html2pdf
2条回答
放我归山
2楼-- · 2019-09-21 04:34

Your HTML output is incomplete.

Try this:

<?php
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));

// build new name and commit
$newname=$_POST['name'].'.pdf';
$html2pdf->Output($newname, 'F');
?>
<html>
<head>
 <title>Test page</title>
<head>
<body>
 <form action="" method="post">
  <input type="text" name="name" />
  <input type="submit" value="Save" />
 </form>
</body>
</html>
查看更多
唯我独甜
3楼-- · 2019-09-21 04:36

this is so old, but maybe somebody else will need the response.

$html2pdf->pdf->setTitle('my nice browser title');

This will control the output of the browser title.

查看更多
登录 后发表回答