convert png to pdf using ghostscript

Viewed 14193

as the title says I am trying to convert png to pdf. I could not find well described example anywhere about this.

I used this command

gs sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=test.pdf test.png

but all I get is

Error: /syntaxerror in (binary token, type=137)
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1894   1   3   %oparray_pop   1893   1   3   %oparray_pop   1877   1   3   %oparray_pop   1771   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push
Dictionary stack:
   --dict:1161/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1

this error message. And now I started wodering if such feature is possible in ghostscript. Should I use other software? ** I'm runing the latest 9.07 version

2 Answers

Yes, image magick can do this no problem - here's the cmd line for looping through all the pngs in a folder and converting to pdf:

cd to the folder with the pngs

mogrify -format pdf -density 300 -units PixelsPerInch *png

Related