Reputation: 45
I am trying to convert jpg images to PDF using GhostScript. I have installed latest version on ghostscript on my Win7 32bit machine.
gswin32c -sDEVICE=pdfwrite -h -r300 -o C:\Docs\MyFile.pdf
C:\gs\gs9.10\lib\viewjpeg.ps -c C:\Docs\123.jpg viewJPEG
It read and created pdf but it is of size 3KB which doesnt show anything in it.
Is something wrong with the above command?
Solved:
I used following command and it converted my jpeg to PDF
gswin32c -sDEVICE=pdfwrite -o stuff%03d.pdf viewjpeg.ps -c "(C:/Docs/grid.jpg) << /PageSize 2 index viewJPEGgetsize 2 array astore >> setpagedevice viewJPEG"
Upvotes: 1
Views: 7692
Reputation: 31141
Yes the command is invalid. -h gives you help at the command line, its not sensible to use that in a real command. You've specified -c which means 'process the next stuff as direct PostScript' and then put the filename directly. '\' is an escape character in PostScript, so you'll end up trying to execute a PostScript command 'CDocs123.jpg' there won't be any such command, so you'll get an error. The pdfwrite device has already opened the PDF file, but the error means no marks are drawn on the page, so you get an empty PDF file.
You need to enclose the filename in parentheses so that it is loaded as a PostScript string, and I'd also recommend using forward slashes:
(c:/Docs/123.jpg)
Upvotes: 2