-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdftest.php
More file actions
36 lines (24 loc) · 700 Bytes
/
pdftest.php
File metadata and controls
36 lines (24 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?PHP
require 'vendor/autoload.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$name = "Massimo";
$mypdf = "
<body style='font-family: Arial, Helvetica, sans-serif'>
<h1>User registration aplication</h1>
<h2>Personal use only</h2>
<h3>Username: $name</h3>
</body>
";
$dompdf->loadHtml($mypdf);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream($name.".pdf");
// Save the file to the server
$output = $dompdf->output();
file_put_contents('uploads/pdf/'.$name.'.pdf', $output);