2017-09-29 9 views
2

어쩌면 저를 도울 수 있습니다. 내가 PDF를 표시 할 때 나는 내가이처럼받을 난 할 것은 다른 측면에서이 코드이상한 문자를 돌려주는 TCPDF

$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'); 

와 HTML 파일을 변환입니다이

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`���� 

같은 몇 가지 이상한 문자를 가지고 만든

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

내가 PDF를 만들 PHP (서버), HTML (페이지를 만들 수)에 extjs (인터페이스), 아약스 (요청시) 및 TCPDF를 사용하고 있습니다.

아이디어가 있으십니까? 사전에

덕분에,

+0

인코딩 문제 일 수 있습니까? "이상한 기호"로 변환을 찾으려면이 항목을 선택하십시오. https://habrastorage.org/storage2/61b/e7a/455/61be7a4552a6650bd19b526db63d4779.png 러시아어로되어 있지만 쉽게 이해할 수 있습니다. –

답변

0

하여 파일의 위치와 다른 웹 페이지에 대답했다 개방 반환 코드는 다음과 같습니다

서버 :

$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'; 

클라이언트 :

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

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

         } 
       } 
      ); 

고마워!

1

당신은 덩어리를 만든 후 물방울 (link)

에 응답을 변환해야합니다, 당신은 URL 객체를 생성 할 수 있습니다 (link)

이 나는 ​​방법이다 pdf를 생성 한 서버 측을 창조하고 프런트 엔드에 표시하십시오.

추가 코드 :

var blob = new Blob(response.responseText, {type: 'application/pdf'}); 
var objectURL = URL.createObjectURL(blob); 
+0

이게 뭔가요? var blob = 새 Blob (response.responseText); objectURL = URL.createObjectURL (BLOB); Ext.getCmp ('winReporteRegistro'). 업데이트 (objectURL); 창 가까이 내가 무엇을 아무것도 :( – Esteban

+1

을 showhing되지 var에 BLOB = 새로운 물방울을 (response.responseText, {유형 : '응용 프로그램/PDF'});. VAR 된 ObjectURL = URL.createObjectURL (BLOB) 개체 URL이 있으면 다운로드 링크로 표시하거나 직접 pdf를 다운로드 할 수 있습니다. [link] (https://stackoverflow.com/questions/19327749/javascript-blob-filename-without-link))는 I = – veggirice

+0

Ext.create ('Ext.window.Window를'윈도우 VAR 윈도우를 추가하려고 { 개수 : [{ 위해 xtype '요소' autoEl { 태그 : "A", HREF : objectURL, html : 'Example.com' } 하이퍼 링크를 표시하지만 운이 아직 없음. 창이 나타나지 않습니다. – Esteban