Skip to content

NOW MANAGED ON CODEBERG

Tweaked pdf export iframe replacement to fix compatibility

Dan Brown42703dd859f6
diff --git a/app/Entities/Tools/ExportFormatter.php b/app/Entities/Tools/ExportFormatter.php
index ebe0020e7..7f377cadb 100644
--- a/app/Entities/Tools/ExportFormatter.php
+++ b/app/Entities/Tools/ExportFormatter.php
@@ -144,6 +144,7 @@ class ExportFormatter
{
$html = $this->containHtml($html);
$html = $this->replaceIframesWithLinks($html);
+
return $this->pdfGenerator->fromHtml($html);
}
@@ -159,7 +160,6 @@ class ExportFormatter
$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 @@ class ExportFormatter
$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 d606617a4..a14f29d4b 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 @@ class PdfGenerator
return $pdf->output();
}
-
-}
\ No newline at end of file
+}