dompdf01.php
# ! /usr/bin/php
<?php
require_once "vendor/autoload.php";
use Dompdf\Dompdf;
$str_out = '<h1>Hello World</h1>';
$str_out .= '<blockquote>';
$str_out .= 'Good Morning<p />';
$str_out .= 'Mar/15/2020<p />';
$str_out .= '</blockquote>';
$dompdf = new Dompdf();
$dompdf->loadHtml($str_out);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
file_put_contents("test01.pdf", $dompdf->output());
?>
PDF の確認方法
evince test01.pdf
ライブラリーのインストール (Ubuntu 21.04)
sudo apt install php7.4-xml
composer require dompdf/dompdf
実行コマンド
./dompdf01.php