1
我試圖下載一個PDF當我點擊一個鏈接。嘗試下載的「Hello world」使用JS和PHP
這是我的代碼:
function issue_bill(order_id){
$.post('orders/issueBilll?id_order='+order_id,
order_id,
function()
{
$('example').replaceWith('Bill issued');
}
);
}
public function executeIssueBill(sfWebRequest $request)
{
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
}
當我點擊鏈接,就不會下載PDF文檔。如果我去的Firebug的督察控制檯的「響應」一節中得到這個如下:
%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/Contents 4 0 R>>
endobj
4 0 obj
<</Filter /FlateDecode /Length 72>>
stream
x�3R��2�35W(�r
Q�w3T04�30PISp
�Z*�[����(hx����+���(j*�d��
endstream
endobj
1 0 obj
<</Type /Pages
/Kids [3 0 R ]
/Count 1
/MediaBox [0 0 595.28 841.89]
>>
endobj
5 0 obj
<</Type /Font
/BaseFont /Helvetica-Bold
/Subtype /Type1
/Encoding /WinAnsiEncoding
>>
endobj
2 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 5 0 R
>>
/XObject <<
>>
>>
endobj
6 0 obj
<<
/Producer (FPDF 1.53)
/CreationDate (D:20110126103602)
>>
endobj
7 0 obj
<<
/Type /Catalog
/Pages 1 0 R
/OpenAction [3 0 R /FitH null]
/PageLayout /OneColumn
>>
endobj
xref
0 8
0000000000 65535 f
0000000228 00000 n
0000000416 00000 n
0000000009 00000 n
0000000087 00000 n
0000000315 00000 n
0000000520 00000 n
0000000596 00000 n
trailer
<<
/Size 8
/Root 7 0 R
/Info 6 0 R
>>
startxref
699
%%EOF
我應該怎麼做下載文件?如果我直接撥打issueBill()
方法,我沒有任何問題可以下載pdf。
完全一樣的。請注意,您將停留在當前頁上,如果你選擇在FPDF的「下載」選項::輸出() – Mchl 2011-01-26 10:05:30