所以,我通过 jQuery 将一些值传递给服务器,这会生成 PDF 乱码。它是这样的:
$.post('/admin/printBatch',
data, // Some vars and such
function(data){
if(data) {
var batch = window.open('','Batch Print','width=600,height=600,location=_newtab');
var html = data; // Perhaps some header info here?!
batch.document.open();
batch.document.write(html);
batch.document.close();
$( this ).dialog( "close" ); // jQuery UI
} else {
alert("Something went wrong, dawg.");
}
return false;
});
输出文件大致如下所示:
$pdf->AddPage(null, null, 'A PDF Page');
//....
$pdf->Output('', 'I'); // 'I' sends the file inline to the browser (http://fpdf.org/en/doc/output.htm)
渲染到浏览器窗口的内容:
%PDF-1.3 3 0 obj <> endobj 4 0 obj <> stream ...
我错过了一些重要的东西,我只知道......想法?
多谢你们。