3

My computer runs on Windows 7 with MikTeX 2.9 and GhostScript 9.02 installed.

I am still confused why do I have to invoke gswin64c.exe rather than ps2pdf.exe to convert ps to pdf?

The switches I want to use are

 -sPAPERSIZE=a4 -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=filename.pdf -c save pop -f filename.ps

When I use ps2pdf.exe with the switch above, it got error message as follows.

enter image description here

Experiment results based on Philippe's comment as follows.

Not working syntax:

  • ps2pdf -sPAPERSIZE=a4 in.ps out.pdf
  • ps2pdf -sPAPERSIZE#a4 in.ps

Working syntax:

  • ps2pdf -sPAPERSIZE#a4 in.ps out.pdf
  • ps2pdf in.ps out.pdf with top margin gets cropped.
  • ps2pdf in.ps with top margin gets cropped.
Display Name
  • 46,933

1 Answers1

6

You don't have to use gswin64c directly. ps2pdf should work. And it does work for me. (TeX Live 2011)

On the other hand, ps2pdf command is actually a script (ps2pdf.exe in TeX Live calls a Lua script ps2pdf.tlu) which calling GhostScript, say, gswin32c.exe or gswin64c.exe.

Usage: ps2pdf [options] (input.[e]ps|-) [output.pdf]

However, the option you use does fails. -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite are defined in ps2pdf script, you don't need them. -sOutputFile can also be replaced. It's safe if you use them, however.

I'm not sure what -c save pop mean. It seems that this option cause the problem. Without this option, everything is Okey.

Leo Liu
  • 77,365
  • I tried ps2pdf.exe -sPAPERSIZE=a4 foo.ps and it works. There may be something wrong with your TeX distribution or GhostScript. I'm not sure. – Leo Liu Jun 04 '11 at 17:02
  • 2
    @xport: under Windows, you usually have to replace the = sign by a # e.g. ps2pdf -sPAPERSIZE#a4 filename.ps – Philippe Goutet Jun 04 '11 at 17:37
  • @xport: No. It's only a bit complex. – Leo Liu Jun 05 '11 at 02:52
  • @xport: try also with ps2pdf -sPAPERSIZE#a4 filename.ps filename.pdf. Do you still have the Unknown paper size: (). error? What error do you have when you just use ps2pdf filename.ps filename.pdf? Have you updated you MikTeX recently? (If it's a bug, it might be fixed.) – Philippe Goutet Jun 05 '11 at 10:00
  • @xport: glad it worked. ps2pdf under Windows is really touchy about syntax. – Philippe Goutet Jun 05 '11 at 17:21
  • @xport: I don't know, all my tries with -c save pop have not been working. I'm not sure what it does. The ghostscript manual says it executes the postscript code save pop but I have no idea what that does. It is mentioned on http://pages.cs.wisc.edu/~ghost/gsview/bugs28.htm related to font bounding box errors. – Philippe Goutet Jun 05 '11 at 18:25