This is probably going to sound like a strange request (trust me that there's a good reason for it), but is it possible to have LaTeX compile straight to an image file instead of to something like PDF, PostScript, or DVI? I know there are probably good ways to convert those formats to an image instead, but I figured I would see if there was a more direct route.

Some requirements:

  • The image format can be either PNG or JPG.
  • I'm not looking just for a single expression or something (I'm aware of tools like tex2im). I want to compile an entire document.
  • There should be one image for each page in the corresponding PDF, with the same resolution, margins, etc. It should be identical to just converting each page faithfully.

In case this turns out to be impossible for some reason, I would also be happy with a simple conversion routine to accomplish this with a PDF generated by pdflatex.


  • 5
    TeX and LaTeX are both designed to output the description of a typeset page. In other words, they target page description languages such as DVI, PostScript or PDF. I doubt you will find a TeX backend that directly targets images since that is not a meaningful format for TeX output. That being said, there are a pile of conversion programs that will do the job.
    – Sharpie
    Aug 14, 2010 at 7:31
  • 2
    You can convert a LaTeX file to PNG using the standalone class, see e.g. Compile a LaTeX document into a PNG image that's as short as possible. However, this is intendend for smaller things, like picture environments and not for whole documents. Feb 5, 2013 at 22:21

3 Answers 3


Probably the best way is latex followed by dvipng. The main advantages over pdflatex followed by pdf2png are: it is faster; it can start working on the dvi while latex is still in the process of producing the dvi. It's optimized for producing screen-resolution antialiased images at maximum speed. If your foo.dvi has 4 pages then you get foo1.png foo2.png foo3.png foo4.png.


You want the preview package. For example, this is what I use for tikz:


You can insert as many tikzpicture env as you wish and each one appears on a single page with the page fit to the image.

  • Hey Leo, thanks for the comment. However, unless I'm misunderstanding your answer and what I found by googling the preview package, this would require me to explicitly wrap each page in an environment. This doesn't quite suit my purpose -- I just want the images to be separated the same way pdflatex separates pages in a PDF -- automatically and at compile-time. Unless I'm missing something, this won't do that. Thanks though :) Aug 14, 2010 at 6:41
  • (The preview package does sound really neat though, and I can see lots and lots of uses for it. Definitely going into my toolbox) Aug 14, 2010 at 6:42
  • 1
    @Adrian: preview is used when you want to create an image from a "semantic" piece of a LaTeX document - a figure, table, equation, etc. - rather than a "visual" piece like a page. In other words, you use preview when the things you want to turn into images are already wrapped by environments. I think Leo may have slightly misread your question.
    – David Z
    Aug 14, 2010 at 8:36
  • if you want the whole page to png/jpg, maybe check out dvipng though I have never used it myself.
    – Leo Liu
    Aug 14, 2010 at 9:29

There is not a way to get a PNG or JPG directly from LaTeX.

My guess is you're attempting to make some web service where users enter LaTeX and get pictures as a result. If this is the case, there are many that do this already and I should caution you that it is unsafe to directly expose LaTeX to the internet. If this is not the case, ignore this graf.

  • Not the case :) I believe there's approximately a billion services that do this already, anyway! Thanks for the feedback though; I guess this leaves me with pdf2png or somesuch? Aug 14, 2010 at 6:43
  • 2
    (The real story, I guess I should mention, is that I'm porting a bunch of documents to an old device which doesn't support new-fangled stuff like PDF or PS, so I'd like to emulate them using images which it can display). Aug 14, 2010 at 6:47
  • 3
    There was a TUG2010 talk on making images for the iPad: river-valley.tv/tex-and-the-ipad. You might want to take a look (I think the process used DVI conversion).
    – Joseph Wright
    Aug 14, 2010 at 6:58
  • @Joseph, thank you, will definitely be watching that :D Aug 14, 2010 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.