]> BookStack Code Mirror - bookstack/commitdiff
Tweaked pdf export iframe replacement to fix compatibility
authorDan Brown <redacted>
Sun, 28 Nov 2021 21:01:35 +0000 (21:01 +0000)
committerDan Brown <redacted>
Sun, 28 Nov 2021 21:01:35 +0000 (21:01 +0000)
Was using a method that wasn't a proper available part of the
DomElement API.

app/Entities/Tools/ExportFormatter.php
app/Entities/Tools/PdfGenerator.php

index ebe0020e75d2302bfa05768e56b231887e418b21..7f377cadb9b06417e23e585fddd470e67d292129 100644 (file)
@@ -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();
index d606617a402d75409babb90c719e31b4a30384cc..a14f29d4b509977f370e82b3fc76c94878b2e9c2 100644 (file)
@@ -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
+}