2010-05-25 20 views
1

嗨兩個問題我使用TCPDF在我的申請,我有大約that.I 2分的問題是能夠得到一個HTML頁面的PDF輸出當我點擊指定按鈕。 我的第一個問題是:當我點擊該按鈕時,如何下載該html的pdf輸出?($ pdf-> lastPage()didn'work)。 我的第二個問題是:我如何設置Trkish字符編碼(我用dejavusans但一些土耳其字符顯示爲問號)我對TCPDF

感謝提前...

回答

2

你應該採取的輸出?看一下例子:http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_examples

我不會建議字符編碼設置爲土耳其語。我建議使用utf8。 (dejavusans不編碼它作爲一種字體)

<?php 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
// create your PDF 
$pdf->Output(); // This will Output the PDF to the Browser if a Plugin is installed or download the PDF file if not 
0

你必須創建按鈕的形式,然後張貼在提交button..see下面的代碼形式。

<br> 
<?php<br> 
if($_POST['download'])<br> 
{<br> 
$strPdfName = 「Myfile」; <br> 
<br> 
include(「pdf/tcpdf.php」); <br> 
<pre> 
$strHtml='write here html'; 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, ‘UTF-8′, false); <br> 

$pdf->setPrintHeader(false); <br> 

$pdf->AddPage(); <br> 

$pdf->SetFont(‘helvetica’, 」, 9); <br> 

$pdf->writeHTML($strHtml, true, 0, true, 0); <br> 

$pdf->lastPage();<br> 

$pdf->Output($strPdfName, ‘D’);<br> 

}<br> 
?> 
+0

作爲警告,請從促進您的博客中不要每次回答你離開這裏。你已經聯繫過這個,所以我強烈建議不要再這樣做。 – 2013-01-01 19:44:22