Batch conversion of PDF file ?

I'm trying to develop a script-fu that would import a PDF file in non interactive mode and generate jpg images for each page. Problem is I couldn't find any example of how to script the PDF import function in batch mode.

Can somebody point me at some sample code or give me a hint on how do that ?

Thanks for your suggestion of using IM to do the job. This is actually what we use right now. However we noticed that in many cases Gimp does a much better job at converting PDF files to Jpeg than IM does. We tried hard to fine tune the various options of the IM convert tool but rarely achieved as good results as Gimp.

-sDEVICE=png16m: the output format (PNG here, you can't worry about quality and use JPG, but thare are also JPG devices if needed )

-r300: the DPI resolution (you can also set an output size in pixels)

-dGraphicsAlphaBits=4 -dTextAlphaBits=4: Sets anti-aliasing for text and graphics to the maximum

-sOutputFile=OPA%02d.png: set the output file names for individual pages to OPA01.png, OPA02.png...

This produces 14 pages in 14 seconds on my Core I5 laptop.

As much as I love Gimp and writing scripts for it, I think its batch mode is barely usable and unless you are using very specific filters or operations, it should be avoided at all costs (and given the options in IM, it is rather easy to avoid).