Skip to content

Commit

Permalink
Add ability to turn off converting entities + fix rendering DejavuSan…
Browse files Browse the repository at this point in the history
…s with footer text (#570)

* Add ability to turn off converting entities

Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £ via dompdf.convert_entities option

* Make render function public

When using custom font (like Dejavu Sans) and getCanvas we need to render the content first (without using output method) to be able to write text (for footer, etc) without corrupting font in PDF (output will corrupt rendered font, helvetica is OK).

Co-authored-by: Barry vd. Heuvel <[email protected]>
  • Loading branch information
pionl and barryvdh authored Jul 13, 2021
1 parent 44c5f21 commit 5ead3e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/dompdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
*/
'show_warnings' => false, // Throw an Exception on warnings from dompdf
'orientation' => 'portrait',
/*
* Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £.
*/
'convert_entities' => true,
'defines' => array(
/**
* The location of the DOMPDF font directory
Expand Down
5 changes: 4 additions & 1 deletion src/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,11 @@ public function setEncryption($password, $ownerpassword = '', $pc = [])
return $this->dompdf->getCanvas()->get_cpdf()->setEncryption($password, $ownerpassword, $pc);
}

protected function convertEntities($subject)
protected function convertEntities($subject)
{
if (false === $this->config->get('dompdf.convert_entities', true)) {
return $subject;
}

$entities = array(
'' => '&euro;',
Expand Down

0 comments on commit 5ead3e0

Please sign in to comment.