2015-11-03 150 views
-4

我想將我的當前網頁導出爲pdf。圖像綠色和藍色是網頁內容和紅色按鈕。當我單擊pdf按鈕時,當前頁面將以pdf格式下載。 。現在,我在load_html中加載了示例文本「示例」。此文本將轉換爲pdf。我想加載整個頁面而不是示例文本。將當前網頁導出爲pdf

enter image description here

<?php 

require_once("dompdf_config.inc.php"); 

$dompdf = new DOMPDF(); 
$dompdf->load_html("<p>sample</p>"); 
$dompdf->set_paper('a4', 'portrait'); 
$dompdf->render(); 

$dompdf->stream("dompdf_out.pdf"); //for downloading automatically 
?> 
+0

http://www.sitepoint.com/convert-html-to-pdf-with-dompdf/ – Suyog

回答

0

更改此$dompdf->set_paper('a4', 'portrait');這個$dompdf->set_paper('A4');

試試這個

require_once("dompdf_config.inc.php"); 

$dompdf = new DOMPDF(); 

$dompdf->load_html("<p>sample</p>"); 
$dompdf->set_paper('A4'); # Changed & No need to mention portrait. This is default 
$dompdf->render(); 

$dompdf->stream("dompdf_out.pdf"); 

紙張大小的字符串,如:letterlegalA4 ....

+0

我需要這與按鈕集成點擊 – user3386779

+0

[製作下載鏈接到DOMPDF生成pdf在同一頁上](http://stackoverflow.com/questions/6987968/making-download-link-to-dompdf-generated-pdf-on-same-page) –

+0

如果我點擊那個按鈕,該頁面可以轉換成pdf – user3386779