Convert pdf to image [jpeg|png]

conversionghostscriptimagemagickpdf

I need to convert pdf files into image files (like: png (prefer), jpeg).

I used convert (from the ImageMagick package) but it takes more than 4 seconds for a 2 page pdf file with only tables (something like an invoice), so this pdf is really light. I found out that convert uses gs to do it. If I do this with gs, the result can be of better quality, and rendered faster.

So I have 3 questions:

  1. Should I use some specific flags in ghostscript package compilation process to make it work faster?
  2. What options for gs can help me get png or jpg files faster and with better quality?
  3. Where can I find documentation about conversion from pdf to image formats?

Best Answer

You can check-out pdfdraw from mupdf (package mupdf-tools under Debian/Debian-derivatives).

From its description:

pdfdraw will render a PDF document to image files. The supported image formats are: pgm, ppm, pam and png. Select the pages to be rendered by specifying a comma separated list of ranges and individual page numbers for example: 1,5,10-15). In no pages are specified all the pages will be rendered.

Perhaps it is faster for your use case.

For example mupdf (a PDF viewer) is really fast (and consumes very little memory) for a lot of documents I tested it with.

Related Question