Esteban Esteban - 1 year ago 92
HTML Question

TCPDF returning weird characters

maybe you can help me. When I try to show a pdf I created I got some weird symbols like this

u\>�'���O���r>c!%�@�R�`YPd+��vv����1��E�'^k-�WD�*+��W^��wy��V Z��dUdJ�B���C�ڳtK����j:c�� �5����50���D3lgH#�}%���D+������ix����,��-�'\�� �_st^&0�Y���������v�*Ӗ,W����u!H��sNN��0cӝ��`xEk��d��^� �8K9�BL�� ��9�̋"6/�E�|�̛�-�7�P��B�#�T�F���4`����


What I do is transform a html file with this code

$html = $this->load->view('ReporteIngresoView', $data, TRUE);
$pdf = new Pdf('P', 'mm', 'A4', TRUE, 'UTF-8', FALSE);
$pdf->SetTitle('Reporte ingreso');
$pdf->SetHeaderMargin(30);
$pdf->SetTopMargin(40);
$pdf->setFooterMargin(20);
$pdf->SetAutoPageBreak(TRUE);
$pdf->SetAuthor('Pontificia Universidad Católica del Ecuador');
$pdf->SetDisplayMode('real', 'default');
$pdf->AddPage();
$pdf->writeHTML($html, TRUE, 0, TRUE, 0);
$pdf->Output('My-File-Name.pdf', 'I');


On the other side I recieve it like this

Ext.Ajax.request
(
{
method: 'post',
url: '../servidor/archivo/ingreso/getreporte',
success: function(response){
Ext.getCmp('winReporteRegistro').update( response.responseText );
}
}
);


I am using php (server), html (create the page), extjs (interface), ajax (request) and TCPDF to create the pdf.

Any ideas?

Thanks in advance,

Answer Source

Returning the location of the file and open that in another web page was the answer, the code is:

Server:

$html = $this->load->view('ReporteCajaView', $data, TRUE);

    $pdf = new Pdf('P', 'mm', 'A4', TRUE, 'UTF-8', FALSE);
    $pdf->SetTitle('Reporte item');
    $pdf->SetHeaderMargin(30);
    $pdf->SetTopMargin(20);
    $pdf->setFooterMargin(20);
    $pdf->SetMargins(25, 20, 20, true);
    $pdf->SetAutoPageBreak(TRUE);
    $pdf->SetAuthor('Universidad Católica');
    $pdf->SetDisplayMode('real', 'default');
    $pdf->setPrintHeader(FALSE);
    $pdf->setPrintFooter(FALSE);
    $pdf->AddPage();

    $id = uniqid();
    $pdf->writeHTML($html, TRUE, 0, TRUE, 0);
    $pathservidor = 'c:/wamp64/www/Archivo/pdf/';
    $pdf->Output($pathservidor . 'Reporte de caja' . '.pdf', 'F');

    echo 'c:/wamp64/www/Archivo/pdf/'.'Reporte de caja'.'.pdf';

Client:

Ext.Ajax.request
            (
                {
                    method: 'post',
                    url: '../servidor/archivo/item/getreporte',

                    success: function(response){
                    window.open(response.responseText);

                       }
                }
            );

Thanks!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download