5
I am generating a PDF report using the dompdf API, and the accentuation words are not being displayed correctly.
I put the charset='utf-8' tag inside the head, but it does not solve the problem
<meta charset='utf-8'/>
In php elements if I do:
<?php echo utf8_decode($variavel); ?>
Content is displayed correctly with accentuation...
*But HTML elements still have accentuation problem...
Example
Code
<?php
ob_start('geraPDF');
?>
<html>
<head>
<meta charset='utf-8'>
<style>
p{
border:1px solid black;
box-shadow:5px 5px 5px #ccc;
width:90%;
padding:5px;
}
</style>
</head>
<body>
<b>Empresa: </b><?php echo utf8_decode($empresas); ?><br>
<b>Data: </b><?php echo date('d/m/Y',strtotime($dt)); ?><br>
<b>Nº da OS: </b><?php echo $os; ?><br>
<b>Nº Orçamento: </b><?php $norcamento; ?><br><br>
</body>
</html>
<?php
// Importa arquivo de config da classe DOMPDF
require_once 'dompdf/dompdf_config.inc.php';
/**
* Função ob_get_clean obtém conteúdo que está no buffer
* e exclui o buffer de saída atual.
* http://br1.php.net/manual/en/function.ob-get-clean.php
*/
$html = ob_get_clean();
$pdf = new DOMPDF();
$pdf->load_html($html);
$pdf->render();
$pdf->stream(date('d/m/Y').'_orcamento.pdf', array('Attachment'=>0));
?>
The result does not come out as expected in the pdf...which may be happening?
Already tried to set the header?
header('Content-type: text/html; charset=UTF-8')
.– Bruno Wego
I believe you will find what need here.
– Bruno Wego
That’s it, problem solved. Thank you! @Bruno Wego
– Charles Fay