因此,我通过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 ...我错过了一些重要的东西,我就是知道...有什么想法?
谢谢你们。
发布于 2011-01-07 06:00:32
我宁愿为弹出窗口设置URL,指向输出PDF的php脚本。
如果您一定要这样做,data-uri可能会有所帮助:
var batch = window.open(
'data:application/pdf,'+encodeURIComponent(data),
'Batch Print',
'width=600,height=600,location=_newtab'
);但我还没有测试过它,即使它在普通浏览器中工作,在IE中也肯定会失败。
https://stackoverflow.com/questions/4620195
复制相似问题