Question

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

Was it helpful?

Solution

Ghostscript can output multiple formats (png included) but I don't believe it is able to take png as an input. You may be able to accomplish your goal using something like imagemagick's convert utility, though: convert test.png test.pdf

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top