2016-09-30 79 views
1

我正在使用jQuery將數據發佈到Yii控制器操作,它將呈現PDF。但是面臨一些問題。FPDF,Yii和jQuery不工作

nom = "toto"; 
$.post(baseUrl+'print/recufrais',{"NomFichier" : nom+'.pdf', "id": code}, 
    function(responde) 
    { 
     console.log(responde); 
    } 
); 

和日誌是:

%PDF-1.3 3 0 OBJ <> endobj 4 0 OBJ <> 流 xeMN0 = b<Ώ dZ @ BlXq- - S$ 「y ͛7 trailer < < /尺寸9 /根8 0 R /信息7 0 R > startxref %% EOF

的操作如下:

public function actionRecufrais() 
{ 
    //header('Content-type: application/pdf'); 
    $NomFichier = $_POST['NomFichier']; 
    $PDF=New phpToPDF(); 
    $PDF->FPDF('P'); 
    $PDF->AddPage(); 

    $PDF->SetFont('Courier','B','15');//$PDF->SetXY(60, 47); 
    $PDF->Ln(); 

    $PDF->MultiCell(0, 15, iconv("UTF-8", "windows-1252", "RECU DE REGLEMENT"), 0, "C", 0); 

    $PDF->SetFont('Courier', 'B', '11'); 
    $PDF->MultiCell(0, 15, iconv("UTF-8", "windows-1252", "NOM ET PRENOMS DE L'ELEVE : "), 0, 'L', 0); 


    $PDF->Output($NomFichier, 'F'); 
    $PDF->Output($NomFichier, 'D'); 
} 

有出亂子用我的代碼?

+0

你沒有嘗試你的代碼沒有ajax ..這是否工作? –

+0

我嘗試過使用GET(使用url http://localhost/app/index.php/print/recufrais/NomFichier/test.pdf),並且一切都很順利。 – sk001

回答

0

哦,不,缺少依賴關係: require_once 'tools/php/functions.php'; $NomFichier = "etats/recufrais/" .$_POST['NomFichier'];

我的控制器操作中。感謝您的關注。