Skip to content

Commit

Permalink
Remove HTML chunking
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasravnsborg committed Nov 8, 2018
1 parent ab8e5bf commit e53a72d
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions src/LaravelPdf/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,7 @@ public function __construct($html = '', $config = [])
$this->config['instanceConfigurator']($this->mpdf);
}

$this->writeHTMLInChunks($html);
}

protected function writeHTMLInChunks($html)
{
$previous_cut = 0;
$html_length = strlen($html);
for($i = 0; $i < $html_length; ++$i)
{
if ($html[$i] == '<' && $i + 1 < $html_length && $html[$i+1] == '/')
{
$ending_char = strpos($html, '>', $i);
$ending_tag = substr($html, $i, $ending_char - $i + 1);
if (preg_match('/^<\/[^>< ]*>/', $ending_tag))
{
$html_chunk = substr($html, $previous_cut, $ending_char - $previous_cut + 1);

$this->mpdf->WriteHTML($html_chunk);

$previous_cut = $i + strlen($ending_tag);
}
}
}
if ($previous_cut < $html_length - 1)
{
$html_chunk = substr($html, $previous_cut, strlen($html) - $previous_cut);

$this->mpdf->WriteHTML($html_chunk);
}
$this->mpdf->WriteHTML($html);
}

protected function getConfig($key)
Expand Down

0 comments on commit e53a72d

Please sign in to comment.