How to Change a PDF to SWF in PHP

Written by declan maher
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Change a PDF to SWF in PHP
Convert PDF to a Flash movie on a website. (Flag of movie image by Yuriy Panyukov from Fotolia.com)

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:
Easy

Other People Are Reading

Instructions

  1. 1

    Download the free conversion program SWFTools (see Resources) and install on the server, following the installation instructions.

  2. 2

    Open a PHP editor, such as Notepad, and create a new PHP page.

  3. 3

    Add the path to where the conversion program is installed (in Step 1):

    $software_path ="C:\SWFTools\pdf2swf" ;

  4. 4

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

  5. 5

    Add the location where the newly created SWF will be stored:

    $swf_output ="C:\SWFTools\abcd.swf" ;

  6. 6

    Add all the arguments into one variable:

    $cmd =" $software_path $pdf_path $argument $swf_output";

  7. 7

    Call the Windows COM object to perform the conversion:

    $WshShell = new COM("WScript.Shell");

  8. 8

    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.

  9. 9

    Save the PHP page and run in a browser, and the PDF will be converted a SWF.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.