Skip to content

Commit

Permalink
Merge pull request #587 from likesistemas/hotfix/encoding
Browse files Browse the repository at this point in the history
🌐 Corrigindo erros de encoding
  • Loading branch information
robmachado authored Nov 28, 2023
2 parents a305570 + ed7aa61 commit d47e811
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Legacy/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public function textBox(
//remover espaços desnecessários
$text = trim($text);
//converter o charset para o fpdf
$text = mb_convert_encoding($text, 'ISO-8859-1');
$text = $this->convertToIso($text);
//decodifica os caracteres html no xml
$text = html_entity_decode($text);
} else {
Expand Down Expand Up @@ -1034,7 +1034,7 @@ public function textBox90(
//remover espaços desnecessários
$text = trim($text);
//converter o charset para o fpdf
$text = mb_convert_encoding($text, 'ISO-8859-1');
$text = $this->convertToIso($text);
//decodifica os caracteres html no xml
$text = html_entity_decode($text);
} else {
Expand Down Expand Up @@ -1117,4 +1117,15 @@ public function textBox90(
$this->rotate(0, $x, $y);
return ($y1 - $y) - $incY;
}

/**
* Converte os caracteres para ISO-88591.
*
* @param string $text
* @return string
*/
private function convertToIso($text) {
return mb_convert_encoding($text, 'ISO-8859-1', ['UTF-8', 'windows-1252']);
}

}

0 comments on commit d47e811

Please sign in to comment.