2013-12-20 58 views

回答

0

我用MPDF(www.mpdf1.com)如下:

(1)緩衝使用ob_start()的輸出

(2)收集所有的輸出入變量$含量= ob_getcontents()

(3)刷新緩衝器,以顯示通過使用ob_flush屏幕上的內容()

(4)創建的PDF作爲文件

因此,像這樣:

// Buffer the output so I can collect the html 
ob_start(); 

// Do the display bit here 

.... 

// Collect into a variable and flush it out 
$content = ob_get_contents(); 
ob_flush(); 

// Make a PDF 
include "MPDF/mpdf.php"; 
$mpdf = new mPDF(); 

// Add some CSS to style content 
$content = "<style>".file_get_contents("style.css").'</style>'.$content; 

// Create PDF and save as file 
$mpdf -> WriteHTML($content); 
$mpdf -> Output('PDF/pdffile.pdf', 'F'); 
相關問題