2011-04-29 44 views
1

我正在使用Google項目API將HTML轉換爲PDF。偉大的工程,是驚人的。你可以在這裏得到它,如果你想: http://code.google.com/p/dompdf/從file_put_contents到服務器上的保存文件

我的問題是這樣的,這個插件做它的魔力,我得到這樣的:

file_put_contents("nameOfPdf.pdf", $pdf); 

如何從這個去將其保存到我的服務器?我是將信息保存到服務器的新手,請詳細介紹一下。

謝謝。

更多CODE這裏

$dompdf = new DOMPDF(); 
    $dompdf->load_html($html); 
    $dompdf->set_paper("a4" , "portrait"); 
    $dompdf->render(); 

    $dompdf->stream("xxxxx.pdf", array("Attachment" => false)); 

    $pdf = $dompdf->output(); 

// You can now write $pdf to disk, store it in a database or stream it 
// to the client. 

    file_put_contents("xxxxx.pdf", $pdf); 
+0

我不明白你的問題是什麼? 「保存到服務器」到底是什麼意思? – 2011-04-29 16:11:05

+0

這個想法是,插件將HTML轉換爲PDF。然後我想將該pdf保存到我的服務器。這有幫助嗎?讓我知道。 – denislexic 2011-04-29 16:13:04

+1

是不是你顯示的那條線沒有這樣做? – 2011-04-29 16:15:16

回答

0

如果我讀docs正確,你需要刪除這一行:

$dompdf->stream("xxxxx.pdf", array("Attachment" => false)); 

將其保存到磁盤,沒有任何輸出。

要指定路徑,請在file_put_contents呼叫中顯示文件名的位置添加路徑。

+0

天才。太感謝了。 – denislexic 2011-04-29 16:28:12

相關問題