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:
Things you need
- Windows platform
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
Download GhostScript from Source Forge and install it.
Launch the command prompt by going to /All Programs/Accessories/Command Prompt or by typing "cmd" in the quick launch bar.
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.
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.
- 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