4

I'm trying to find a method of converting a PDF to high quality JPG previews on a linux box.

I'm currently using ImageMagicK + GhostScript but I have to supersample the images so much to get readable quality that it takes forever to process (30+ seconds on my box for one page).

Does anyone know of a better method where I can achieve high quality previews without having to supersample so much?

Thanks!

multipolygon
  • 2,194
  • 2
  • 19
  • 23
Mike
  • 41
  • 2
  • I am not sure if a Java product will suit your needs but this article - [Convert PDF To High-Resolution Images Using Java](http://www.gnostice.com/nl_article.asp?id=135&t=Convert_PDF_To_High-Resolution_Images_Using_Java) - was written for our product Gnostice PDFOne. – BZ1 Feb 17 '11 at 04:14
  • Thanks for the response. Unfortunately I can't fork out 500 bucks. :( – Mike Feb 17 '11 at 04:46

2 Answers2

8

I found pdftoppm installed on my Ubuntu Linux box.

pdftoppm -f 1 -l 1 -scale-to 1024 -png input-file.pdf output-file
  • The output is high-quality when -scale-to px is large
  • The conversion is quite fast
  • My command above creates a preview for just the first page (-f 1 -l 1)
  • Output-file seems to be of the format: output-file-1.png (where 1 is the page number)
multipolygon
  • 2,194
  • 2
  • 19
  • 23
  • And if you have to work with a platform where all packages are at least five years old \*cough*CentOS*cough\*, `pdftoppm` won’t know about the `-scale-to` or `-png` options, so you use the `-r` option instead, let it convert to ppm, and then use ImageMagick to convert from ppm to PNG. – Olivier 'Ölbaum' Scherler Oct 24 '12 at 06:17
0

First you convert your pdf to ps using pdf2ps command

pdf2ps file.pdf file.ps

Then you can further process the output to jpg using ImageMagick's convert

convert -resample 300 file.ps file.jpg

Andreas Wong
  • 59,630
  • 19
  • 106
  • 123