Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added conversion of iframes to anchors on PDF export
- Replaced iframe elements with anchor elements wrapped in a paragraph. - Extracted PDF generation action to seperate class for easier mocking within testing. - Added test to cover. For #3077
- Loading branch information
1 parent
709533c
commit 2c21850
Showing
3 changed files
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace BookStack\Entities\Tools; | ||
|
||
use Barryvdh\Snappy\Facades\SnappyPdf; | ||
use Barryvdh\DomPDF\Facade as DomPDF; | ||
|
||
class PdfGenerator | ||
{ | ||
|
||
/** | ||
* Generate PDF content from the given HTML content. | ||
*/ | ||
public function fromHtml(string $html): string | ||
{ | ||
$useWKHTML = config('snappy.pdf.binary') !== false && config('app.allow_untrusted_server_fetching') === true; | ||
|
||
if ($useWKHTML) { | ||
$pdf = SnappyPDF::loadHTML($html); | ||
$pdf->setOption('print-media-type', true); | ||
} else { | ||
$pdf = DomPDF::loadHTML($html); | ||
} | ||
|
||
return $pdf->output(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters