2013-06-21 29 views
0

可以將PDF轉換爲SWF動態嗎?我一直在嘗試,但事實證明這很困難。可以動態地將pdf轉換爲swf嗎?

這裏是我的代碼:

<?php 
include('include\settings.php'); 

$title = "k"; 
$makeswf= mysql_query("SELECT * FROM books WHERE title = '$title'"); 
$rows = mysql_num_rows($makeswf); 

if ($rows !=0) 
{ 
while($rows = mysql_fetch_assoc($makeswf)) 
{ 

//where blocation is the pdf file need to be converted. 

$file = $rows['blocation']; 

echo exec('D:\wamp\www\dspzlibrary\converter\pdf2swf.exe books\$file.pdf -o books\$file.swf -f -T 9 -t -s storeallcharacters'); 
} 

    } 

else 
echo"empty"; 

?> 

這裏是我收到的錯誤:

錯誤無法打開書\ $ file.pdf

的任何援助都不勝感激。

+0

「這裏是代碼」 - 我想你可能忘記在那裏發佈代碼。 –

+0

代碼未被格式化。 php標籤導致它被忽略顯示。 –

回答

1

錯誤消息告訴你發生了什麼事。可執行文件pdf2swf.exe正試圖打開$file.pdf,而不是實際的文件名。

在PHP中,內聯變量替換需要雙引號「」。

echo exec("D:\wamp\www\dspzlibrary\converter\pdf2swf.exe books\$file.pdf -o books\$file.swf -f -T 9 -t -s storeallcharacters"); 

參見:http://php.net/manual/en/language.types.string.php

雙引號字符串最重要的特徵是,變量名稱將擴大。

+0

現在仍然沒有鎖定「」雙引號 – user1942471

+0

請幫忙:這個工作代碼: – user1942471