In more recent years chrome headless has drastically improved for rendering html to
direct PDF output, there can be limitations so not always suited to everyone.
One UpToDate project to "Make PDF" on a PHP base is https://github.com/chrome-php/chrome
Requirements
Requires PHP 7.3-8.2 and a chrome/chromium 65+ executable.
example usages
// get page title
$pageTitle = $page->evaluate('document.title')->getReturnValue();
// screenshot - Say "Cheese"!
$page->screenshot()->saveToFile('/foo/bar.png');
// pdf
$page->pdf(['printBackground' => false])->saveToFile('/foo/bar.pdf');
It has many API type abilities and is actively maintained at present with few open issues, however it will be restricted by chromes accessible options.