4

I am using TexShop on a Mac, which handles all of the rendering for me, but have been asked by a colleague to find the command(s) that would render the LaTex document as a PNG instead of PDF.

By way of example, on linux it would be

$ pdflatex file.tex
$ gs -sDEVICE=pnggray -sOutputFile=card.png -dNOPAUSE -r1200 file.pdf quit.ps

(Note: the -r1200 will generate an image 4x larger than used, since it will be scaled down to produce an anti-aliased image).

Thank you & kind regards.

Rax Adaam
  • 1,747
  • 2
    OSX is unix, so you can probably issue the GS command the same way. – Matthew Leingang Jun 11 '13 at 16:08
  • You can use convert. – Marco Daniel Jun 11 '13 at 16:10
  • where did the file quit.ps come from in the command you show? Is this command supposed to convert a PDF file to PNG image? So a 100 pages pdf file will be converted to one png image? becuase when I just tried it on 16 pages pdf file: gs -sDEVICE=pnggray -sOutputFile=card.png -dNOPAUSE -r1200 index.pdf then when it is done, I get the GS> prompt. Now I typed quit and then looked at card.png but it only shows the first page of the pdf file only. How is this supposed to work? – Nasser Jun 11 '13 at 17:00
  • There are two commands: sips and convert. – Pouya Jun 11 '13 at 18:32

1 Answers1

5

The Mac OS is Unix-based, so at the Terminal

pdflatex <filename> && gs -sDEVICE=pnggray -sBATCH -sOutputFile=<filename>.png -dNOPAUSE -r1200 <filename>.pdf

should work just fine. (Fill in your <filename>, of course.)

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036