[Tex/LaTex] Why can’t I get pstricks with auto-pst-pdf (and cropping) running on MikTeX

compilingghostscriptmiktexpdftexpstricks

\documentclass{minimal}
\usepackage[pdf]{pstricks}

\begin{document}

\begin{pspicture}(-5.25,-5.25)(5.25,5.25)%
  \pscircle*[linecolor=cyan]{5}
  \psgrid[subgriddiv=0,gridcolor=lightgray,gridlabels=0pt]
  \Huge\sffamily\bfseries
  \rput(-4.5,4.5){A} \rput(4.5,4.5){B}
  \rput(-4.5,-4.5){C}\rput(4.5,-4.5){D}
  \rput(0,0){auto-pst-pdf}
  \rmfamily
  \rput(0,-3.8){PSTricks}
  \rput(0,3.8){\LaTeX}
\end{pspicture}

\end{document}

I run it with:

pdflatex -shell-escape Test.tex > log.txt 2>&1

But stdout says:

PDFCROP 1.33, 2012/02/01 - Copyright (c) 2002-2012 by Heiko Oberdiek.
!!! Error: Ghostscript exited with error code 1!

The same happens when using \usepackage{pstricks} \usepackage{auto-pst-pdf}.

If I use \usepackage{pstricks} \usepackage[crop=off]{auto-pst-pdf} then it works!

I use Windows 7 x64, MikTeX 2.9 x86 (complete system) with latest packages, installed latest ActivePerl x86 and also applied the pdfcrop fix (as the related problem appeared earlier).

You see all details in the logs for stdout, Test.log, and Test-autopp.log.

Any ideas?

UPDATE: I tried to manually run pdfcrop and got the same error. When I run it with –debug I see that it can't locate the Ghostscript executable gswin32c.exe. I looked into the MikTeX bin/ folder because I thought it is there, but it isn't. Do I have to install Ghostscript separately?

Best Answer

I made some test with miktex 2.9.: auto-pst-pdf with pdfcrop works for me only if an external perl is in the path. An external ghostscript is not necessary. This here is the "minimal working path" (I guess the windows path is needed for cmd.exe):

Path=J:\MiKTeX2.9\miktex\bin;C:\WINDOWS\system32;J:\Perl\bin;