简体   繁体   中英

How to install DomPDF

I'm trying to install DomPDF, but I can only get an error saying: This page isn't working mydomain.com is currently unable to handle this request. HTTP ERROR 500

I've uploaded the DomPDF files on my server from here https://github.com/dompdf/dompdf and in a folder call /dompdf/

Here is the html file:

<html>
<head>
<link href="style.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div id="wrapper">

<div id="html_div">
 <form action="/dompdf/generate_pdf.php" method="post">
  <input type="text" name="name" placeholder="Enter Name">
  <br>
  <input type="text" name="email" placeholder="Enter Email">
  <br>
  <input type="text" name="age" placeholder="Enter Age">
  <br>
  <input type="text" name="country" placeholder="Enter Country">
  <br>
  <input type="submit" name="submit_val" value="GENERATE PDF">
 </form>
</div>

</div>
</body>
</html>

And the PHP file:

<?php
namespace Dompdf;
require_once '/dompdf/autoload.inc.php';

if(isset($_POST['submit_val']))
{
$dompdf = new Dompdf(); 
$dompdf->loadHtml('
<table border=1 align=center width=400>
<tr><td>Name : </td><td>'.$_POST['name'].'</td></tr>
<tr><td>Email : </td><td>'.$_POST['email'].'</td></tr>
<tr><td>Age : </td><td>'.$_POST['age'].'</td></tr>
<tr><td>Country : </td><td>'.$_POST['country'].'</td></tr>
</table>
');
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream("",array("Attachment" => false));
exit(0);
}
?>

you are downloading the source code, the inc file does not exist there yet.

i assume you're not using composer, so you need to download the release asset, (not source)

here>> https://github.com/dompdf/dompdf/releases

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM