crawly/html-to-pdf

Lib para converter HTML em PDF de uma maneira segura para as necessidades dos crawlers.

1.0.0 2020-09-11 22:13 UTC

This package is auto-updated.

Last update: 2024-04-15 04:47:30 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();