【发布时间】:2016-09-30 10:22:25
【问题描述】:
我正在使用 jQuery 将数据发布到将呈现 pdf 的 Yii 控制器操作。但面临一些问题。
nom = "toto";
$.post(baseUrl+'print/recufrais',{"NomFichier" : nom+'.pdf', "id": code},
function(responde)
{
console.log(responde);
}
);
日志是:
%PDF-1.3 3 0 对象 结束对象 4 0 对象 溪流 x�e�MN�0��=����b 起始外部参照 987 %%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');
}
我的代码有问题吗?
【问题讨论】:
-
您是否尝试过不使用 ajax 的代码。这是否有效??
-
我尝试使用 GET(使用 url localhost/app/index.php/print/recufrais/NomFichier/test.pdf),一切顺利。