所以,我通过jQuery将一些值传递给服务器,这会生成PDF格式的垃圾文件。它是这样的:是否可以通过JavaScript呈现PDF(fPDF)?
$.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 ...
我失去了一些东西重要,我只知道它......想法?
谢谢,伙计们。
Hello LaRosee,你有没有解决上述问题的方法? – user98454 2011-03-16 11:59:10