开发者

How to convert .pdf to .png

开发者 https://www.devze.com 2023-01-18 10:32 出处:网络
Using ImageMagick I can convert any pdf document into images by using command \"convert\": convert abc.pdf abc.png

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 th开发者_StackOverflow中文版at I can provide this functionality on my website to enable users to read books online as Google Books does.


There is a Java API for ImageMagick called JMagick.

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


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


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();


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号