Untitled

 avatar
unknown
php
2 years ago
1.2 kB
6
Indexable
<?php

use Dompdf\Dompdf;

require 'vendor/autoload.php';

$html = <<<HTML
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">

<style>
    .v {
        font-family: 'VT323', monospace;
    }
</style>
</head>
<body>
    <p class="v" style="font-size: 72px">
        ŻŻĘĘĘĘĄŚŚĆĆŹŹ
    </p>
</body>
</html>
HTML
;

//$_dompdf_show_warnings = true;
//$_dompdf_debug = true;

$tmp = sys_get_temp_dir();

$dompdf = new Dompdf([
    'logOutputFile' => '',
    // authorize DomPdf to download fonts and other Internet assets
    'isRemoteEnabled' => true,
    // all directories must exist and not end with /
    'fontDir' => $tmp,
    'fontCache' => $tmp,
    'tempDir' => $tmp,
    'chroot' => $tmp,
]);

$dompdf->loadHtml($html); //load an html

$dompdf->render();

$dompdf->stream('hello.pdf', [
    'compress' => true,
    'Attachment' => false,
]);
Editor is loading...