mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-04 16:20:26 +00:00
Tweaked pdf export iframe replacement to fix compatibility
Was using a method that wasn't a proper available part of the DomElement API.
This commit is contained in:
parent
2c21850da7
commit
42703dd859
2 changed files with 4 additions and 6 deletions
app/Entities/Tools
|
@ -144,6 +144,7 @@ class ExportFormatter
|
||||||
{
|
{
|
||||||
$html = $this->containHtml($html);
|
$html = $this->containHtml($html);
|
||||||
$html = $this->replaceIframesWithLinks($html);
|
$html = $this->replaceIframesWithLinks($html);
|
||||||
|
|
||||||
return $this->pdfGenerator->fromHtml($html);
|
return $this->pdfGenerator->fromHtml($html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +160,6 @@ class ExportFormatter
|
||||||
$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
$doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
||||||
$xPath = new DOMXPath($doc);
|
$xPath = new DOMXPath($doc);
|
||||||
|
|
||||||
|
|
||||||
$iframes = $xPath->query('//iframe');
|
$iframes = $xPath->query('//iframe');
|
||||||
/** @var DOMElement $iframe */
|
/** @var DOMElement $iframe */
|
||||||
foreach ($iframes as $iframe) {
|
foreach ($iframes as $iframe) {
|
||||||
|
@ -172,7 +172,7 @@ class ExportFormatter
|
||||||
$anchor->setAttribute('href', $link);
|
$anchor->setAttribute('href', $link);
|
||||||
$paragraph = $doc->createElement('p');
|
$paragraph = $doc->createElement('p');
|
||||||
$paragraph->appendChild($anchor);
|
$paragraph->appendChild($anchor);
|
||||||
$iframe->replaceWith($paragraph);
|
$iframe->parentNode->replaceChild($paragraph, $iframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $doc->saveHTML();
|
return $doc->saveHTML();
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
|
|
||||||
namespace BookStack\Entities\Tools;
|
namespace BookStack\Entities\Tools;
|
||||||
|
|
||||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
|
||||||
use Barryvdh\DomPDF\Facade as DomPDF;
|
use Barryvdh\DomPDF\Facade as DomPDF;
|
||||||
|
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||||
|
|
||||||
class PdfGenerator
|
class PdfGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate PDF content from the given HTML content.
|
* Generate PDF content from the given HTML content.
|
||||||
*/
|
*/
|
||||||
|
@ -24,5 +23,4 @@ class PdfGenerator
|
||||||
|
|
||||||
return $pdf->output();
|
return $pdf->output();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue