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
  • 206,299
  • 34
  • 391
  • 426
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,264
  • 15
  • 20
3

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

Community
  • 1
  • 1
sdorra
  • 2,434
  • 17
  • 15
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
  • 58,502
  • 12
  • 138
  • 147
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,010
  • 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,061
  • 3
  • 23
  • 29