How to Convert PDF to JPG with PHP

Written by andante sostenuto
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Convert PDF to JPG with PHP
(Ciaran Griffin/Stockbyte/Getty Images)

You can convert a PDF file into a JPG image without taking a screenshot and uploading it yourself through PHP, provided you have the multimedia libraries already installed.

Skill level:
Easy

Other People Are Reading

Things you need

  • ImageMagick
  • GhostScript
  • Windows platform

Show MoreHide

Instructions

  1. 1

    Download ImageMagick from its website if you do not have it already installed. To do this, go to the subdirectory /binaries/ and download one of the following, then install it:

    ImageMagick-6.5.9-0-Q16-windows-dll.exe ImageMagick-6.5.9-0-Q16-windows-static.exe ImageMagick-6.5.9-0-Q8-windows-dll.exe ImageMagick-6.5.9-0-Q8-windows-static.exe

  2. 2

    Download GhostScript from Source Forge and install it.

  3. 3

    Launch the command prompt by going to /All Programs/Accessories/Command Prompt or by typing "cmd" in the quick launch bar.

  4. 4

    Try converting a PDF file. Go to a directory where there is a PDF file, then type:

    convert yourpdfname.pdf yourpdfname.jpg

    Check your source folder again to see the JPG image versions of your PDF file.

  5. 5

    Now, to run this as a script in PHP, simply call on the convert function:

    exec("convert yourpdfname.pdf yourpdfname.jpg")

Tips and warnings

  • Make sure you have a PDF file in the directory you are in, otherwise the function won't be able to work.
  • When you install ImageMagick, make sure to check "Add application directory to your system path" or it won't work properly.

Don't Miss

Resources

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.