www.flickr.com

Wednesday, December 06, 2006

ps2pdf tip: How to Get Around the "broken" ps2pdf Arguments

I through hours with a ps2pdf problem. Thank God someone on the PostScript news group managed to help me out. Here's the story for posterity's sake.

I'm currently working on a LaTeX document with some photos in it. As I'm using the PowerDot class, which is incompatible with pdflatex, I need to convert all my images to EPS and use ps2pdf to get my final PDF document. On the first attempt, I used the command

ps2pdf file.ps file.pdf

and it worked, except that my photos came out all muddy, a result of over compression. So, I added the option to turn off compression,

ps2pdf -dEncodeColorImages=false file.ps file.pdf

and end up with the wonderfully obtuse error message

Error: /undefinedfilename in (false)
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1122/1686(ro)(G)-- --dict:0/20(G)-- --dict:70/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
MiKTeX GPL Ghostscript 8.54: Unrecoverable error, exit code 1

Ick.

It turns out that ps2pdf on Windows is a batch file, and batch files do not accept = in an argument. I had no idea that this was the case, but so it is. The solution, which is annoyingly absent in the documentation, is to replace = with #. Thus, the command on windows should be,

ps2pdf -dEncodeColorImages#false file.ps file.pdf

Like that, it works. And, I get my beautiful uncompressed photos in my document.

11 comments:

  1. I had the same problem, thank you!

    ReplyDelete
  2. Me too! Thanks!

    ReplyDelete
  3. And me! Thanks a million!

    ReplyDelete
  4. Thanks a lot!!! I finally find the solution of my problem!!!!!

    ReplyDelete
  5. it is in the docs, at http://pages.cs.wisc.edu/~ghost/doc/cvs/Use.htm#MS_Windows
    However I found the solution here, and only then remembered seeing something about this, years ago, and dug it up. So thanks for posting :)

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Yup, helpfully the documentation on MS Windows only seems to be in new versions of Ghostscript (8.6+) so it seems in this case, Google Search is the wrong thing to do!

    ReplyDelete
  8. oh man I spent 4 hours with this...

    ReplyDelete
  9. Thanks, very helpful! :)

    ReplyDelete
  10. Thanks so much for posting this. I was banging my head against the wall about this one.

    ReplyDelete