crawly / html-to-pdf
Lib para converter HTML em PDF de uma maneira segura para as necessidades dos crawlers.
Installs: 3 536
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- ext-dom: *
- ext-libxml: *
- ext-mbstring: *
- mikehaertl/phpwkhtmltopdf: ^2.4
This package is auto-updated.
Last update: 2024-11-15 06:00:46 UTC
README
Lib para converter HTML em PDF de uma maneira segura para as necessidades dos crawlers.
Instalação
composer require crawly/html-to-pdf
Exemplo de uso
<?php
use Crawly\HtmlToPdf;
$html = file_get_contents('my.html');
$htp = new HtmlToPdf($html);
$htp->setBaseUrl('http://www.detran.mg.gov.br')
->safeStripTags()
->sanitizeHtmlHeader()
->sanitizeHtmlText()
->setOptions([
'commandOptions' => [
'useExec' => false,
],
'javascript-delay' => '10000',
'ignoreWarnings' => false
])
->customTransform(function ($html) {
return str_replace('abrir-fechar-table', 'abrir-fechar-table aberto', $html);
});
$pdfBase64 = $htp->convert();