📜  使用 php.php 代码示例将 html 转换为 pdf

📅  最后修改于: 2022-03-11 14:54:29.135000             🧑  作者: Mango

代码示例1









'; //Step 2. Make a PHP file to generate PDF namespace Dompdf; require_once 'dompdf/autoload.inc.php'; if(isset($_POST['submit_val'])) { $dompdf = new Dompdf(); $dompdf->loadHtml('
Name : '.$_POST['name'].'
Email : '.$_POST['email'].'
Age : '.$_POST['age'].'
Country : '.$_POST['country'].'
'); $dompdf->setPaper('A4', 'landscape'); $dompdf->render(); $dompdf->stream("",array("Attachment" => false)); exit(0); } ?> //CSS body { margin:0 auto; padding:0px; text-align:center; width:100%; font-family: "Myriad Pro","Helvetica Neue",Helvetica,Arial,Sans-Serif; } #wrapper { margin:0 auto; padding:0px; text-align:center; width:995px; } #wrapper h1 { margin-top:50px; font-size:45px; color:#585858 } #wrapper h1 p { font-size:18px; } #wrapper a { color:blue; font-size:20px; } #html_div input[type="text"] { margin-top:5px; width:250px; height:35px; padding:10px; } #html_div input[type="submit"] { background-color:#585858; width:250px; height:35px; border:none; margin-top:5px; color:white; margin-left:-5px; }