user1942471
user1942471

Reputation: 1

Can one convert pdf to swf dynamically?

Can one convert PDF to SWF dynamically? I have been trying, but it proved to be difficult.

Here is my code:

<?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";

?>

And here is the error I received:

ERROR Couldn't open books\$file.pdf

Any assistance will be appreciated.

Upvotes: 0

Views: 935

Answers (1)

Eric J.
Eric J.

Reputation: 150158

The error message is telling you what is happening. The executable pdf2swf.exe is trying to open $file.pdf, rather than the actual file name.

In PHP, you need double quotes "" for inline variable substitution.

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

See: http://php.net/manual/en/language.types.string.php

The most important feature of double-quoted strings is the fact that variable names will be expanded.

Upvotes: 1

Related Questions