0

Using ImageMagick I can convert any pdf document into images by using command "convert":

convert abc.pdf abc.png

This will convert all pdf pages to png images.

How can I implement this using PHP or Java so that I can provide this functionality on my website to enable users to read books online as Google Books does.

dtb
  • 213,145
  • 36
  • 401
  • 431
Shashank
  • 1
  • 1
  • 1
  • 2

5 Answers5

4

There is a Java API for ImageMagick called JMagick.

Here is a list of available ImageMagick APIs for various languages.

vls
  • 2,304
  • 15
  • 20
3

You could use Java and the pdf-renderer library. Look at this post.

Community
  • 1
  • 1
sdorra
  • 2,382
  • 18
  • 16
2

In Java you can call Ghostscript from the command line. Ghostscript is freely available.

ProcessBuilder processBuilder = new ProcessBuilder("C:\\Programme\\gs\\gs9.00\\bin\\gswin32c.exe", "-dSAFER", "-dBATCH", "-dNOPAUSE", "-sDEVICE=pngalpha", "-r300", "-sOutputFile=C:\\TemplateEditor\\AdGenXTest\\Testdaten\\ActualPNGs\\" + fileName + ".png", "C:\\TemplateEditor\\AdGenXTest\\Testdaten\\ActualPDFs\\" + fileName + ".pdf");

processBuilder.start();
Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
Sonja
  • 29
  • 1
1

There is a very good ImageMagick module for PHP. Read all about it at http://php.net/manual/en/book.imagick.php

Habbie
  • 2,150
  • 15
  • 17
0

Maybe JPedal Java PDF library can help you?

On they site you can find some demo about converting PDF to image: PDF to text and PDF to Image Conversion

Lukasz Stelmach
  • 5,281
  • 4
  • 25
  • 29