diff --git a/app/Entities/Tools/ExportFormatter.php b/app/Entities/Tools/ExportFormatter.php index ebe0020e75d..7f377cadb9b 100644 --- a/app/Entities/Tools/ExportFormatter.php +++ b/app/Entities/Tools/ExportFormatter.php @@ -144,6 +144,7 @@ protected function htmlToPdf(string $html): string { $html = $this->containHtml($html); $html = $this->replaceIframesWithLinks($html); + return $this->pdfGenerator->fromHtml($html); } @@ -159,7 +160,6 @@ protected function replaceIframesWithLinks(string $html): string $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); $xPath = new DOMXPath($doc); - $iframes = $xPath->query('//iframe'); /** @var DOMElement $iframe */ foreach ($iframes as $iframe) { @@ -172,7 +172,7 @@ protected function replaceIframesWithLinks(string $html): string $anchor->setAttribute('href', $link); $paragraph = $doc->createElement('p'); $paragraph->appendChild($anchor); - $iframe->replaceWith($paragraph); + $iframe->parentNode->replaceChild($paragraph, $iframe); } return $doc->saveHTML(); diff --git a/app/Entities/Tools/PdfGenerator.php b/app/Entities/Tools/PdfGenerator.php index d606617a402..a14f29d4b50 100644 --- a/app/Entities/Tools/PdfGenerator.php +++ b/app/Entities/Tools/PdfGenerator.php @@ -2,12 +2,11 @@ namespace BookStack\Entities\Tools; -use Barryvdh\Snappy\Facades\SnappyPdf; use Barryvdh\DomPDF\Facade as DomPDF; +use Barryvdh\Snappy\Facades\SnappyPdf; class PdfGenerator { - /** * Generate PDF content from the given HTML content. */ @@ -24,5 +23,4 @@ public function fromHtml(string $html): string return $pdf->output(); } - -} \ No newline at end of file +}