A Portable Document Format, or PDF, is a formatted document that will appear on the recipient's monitor or printer in a standard way. A SWF or Flash file is often used for movies, games and graphics. Automating PDF to SWF file conversion means you can convert and show a PDF as a movie on a website.
- Skill level:
Other People Are Reading
Download the free conversion program SWFTools (see Resources) and install on the server, following the installation instructions.
Open a PHP editor, such as Notepad, and create a new PHP page.
Add the path to where the conversion program is installed (in Step 1):
$software_path ="C:\SWFTools\pdf2swf" ;
Create a variable with the path to where the PDF is located and set the argument variable:
$pdf_path ="C:\SWFTools\abcd.pdf" ;
$argument = "-o";
Add the location where the newly created SWF will be stored:
$swf_output ="C:\SWFTools\abcd.swf" ;
Add all the arguments into one variable:
$cmd =" $software_path $pdf_path $argument $swf_output";
Call the Windows COM object to perform the conversion:
$WshShell = new COM("WScript.Shell");
Run the WshShell object from the command line:
$oExec = $WshShell->Run("cmd /C $cmd ", 0, true);
Set the argument in the Run command to "0" if you do not want to display the newly created SWF. Otherwise, set this to "3" and the Flash movie will be shown. The script generates one SWF frame per PDF page.
Save the PHP page and run in a browser, and the PDF will be converted a SWF.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for