PDF created with Html2pdf and how to save different name for pdf document

时光毁灭记忆、已成空白 提交于 2019-12-13 11:01:10

问题


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>

回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/9465256/pdf-created-with-html2pdf-and-how-to-save-different-name-for-pdf-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!