2017-04-06 113 views
0

嘗試使用笨,以顯示TCPDF的畫面時,我有一個問題,無法獲取圖像(笨,TCPDF,PHP)的大小

這是我的PDF查看:

$base_url=base_url(); 

// NON-BREAKING ROWS (nobr="true") 

$tbleauproduct = <<<EOD 
<br /><br /><br /> 
<table border="1" align="center"> 
    <tr> 
     <th>picture</th> 
     <th>Product name</th> 
     <th>Price</th> 
     <th>Quantity</th> 
    </tr> 
    <tr> 
     <td><img src="$base_url/assets/$picture" /></td> 
     <td>$name</td> 
     <td>$price</td> 
     <td>$qty</td> 
    </tr> 
</table> 
EOD; 

$pdf->writeHTML($tbleauproduct, true, false, true, false, ''); 

和這是結果:

TCPDF ERROR: [Image] Unable to get the size of the image: http://localhost:8888/open_bay//assets/130501153059-htc-one-1024x576.jpeg 
+0

PDF不是圖像。 – Narf

+0

可能重複的[TCPDF錯誤:無法獲取圖像的大小](http://stackoverflow.com/questions/27060947/tcpdf-error-unable-to-get-the-size-of-the-image) –

+0

避免張貼圖像的代碼。始終將代碼作爲文本發佈。我已經替換了你的圖片。 – mickmackusa

回答

0
$file_path = base_url().'assets/130501153059-htc-one-1024x576.jpeg'; 
$size = filesize($file_path); 
+0

我使用這種方法,但我發現這個問題:消息:文件大小():stat失敗http:// localhost:8888/open_bay/assets/130501153059-htc-one-1024x576.jpeg –

+1

僅有代碼的答案可以通過改進提供解釋或可能鏈接到官方文件。答案不僅幫助OP解決問題,而且幫助未來的SO研究人員快速解決問題。讓每個帖子都可以達到最高質量,並且您可以站得更高,從upvotes獲得更多的rep點。 – mickmackusa