Clean a HTML/XML input to be generated in PDF by psliwa/php-pdf library.
composer require rezozero/pdfsafe
Add this extension in your Twig environment.
use RZ\PdfSafe\PdfSafeExtension;
use Symfony\Component\HttpFoundation\Request;
$container->extend('twig.extensions', function ($extensions, $c) {
/** @var Request $request */
$request = $c['request'];
$extensions->add(new PdfSafeExtension($request->getSchemeAndHttpHost()));
return $extensions;
});