Pdfcrop:无法在命令提示符中调用 ghostscript‘mgs’

Pdfcrop:无法在命令提示符中调用 ghostscript‘mgs’

在 Windows 10 上,我尝试pdfcrop a.pdf从命令提示符调用,但出现以下错误:

!!! Error: Cannot call ghostscript `mgs.exe' (No such file or directory/The system cannot find the file specified)!

我已经检查过C:\Program Files\MikTeX 2.9\miktex\bin\x64\在我的 中Path,并且mgs.exe是在 中C:\Program Files\MikTeX 2.9\miktex\bin\x64\。我尝试运行pdfcrop a.pdf --gscmd=mgs.exe,但只是得到

!!! Error: Cannot call ghostscript `mgs.exe' (No such file or directory/The system cannot find the file specified)!

编辑:奇怪的是,pdfcrop a.pdf在 git shell 中执行有效。我现在对这个问题更加不了解了。

编辑 2:该命令mgs在 git shell 和命令提示符中均可用。

编辑 3:...>pdfcrop --debug产生

...>pdfcrop --debug
* Perl executable: C:\Perl64\bin\perl.exe
* Perl version: v5.24.2
* Perl product: ActivePerl, build 2403
* Pointer size: 8
* Pipe support: yes
* Fork support: no
* OS name: MSWin32
* Arch name: MSWin32-x64-multi-thread
* System: miktex
* Not found (mgs): mgs.exe
* Found (mgs): C:\Program Files\MiKTeX 2.9\miktex\bin\x64\mgs.exe
* Autodetected ghostscript command: mgs
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
Syntax:   pdfcrop [options] <input[.pdf]> [output file]
Function: Margins are calculated and removed for each page in the file.
Options:                                                       (defaults:)
--help              print usage
--version           print version number
--(no)verbose       verbose printing                         (true)
--(no)debug         debug informations                       (true)
--gscmd <name>      call of ghostscript                      (mgs)
--pdftex | --xetex | --luatex
                  use pdfTeX | use XeTeX | use LuaTeX      (pdftex)
--pdftexcmd <name>  call of pdfTeX                           (pdftex)
--xetexcmd <name>   call of XeTeX                            (xetex)
--luatexcmd <name>  call of LuaTeX                           (luatex)
--margins "<left> <top> <right> <bottom>"                    (0 0 0 0)
                  add extra margins, unit is bp. If only one number is
                  given, then it is used for all margins, in the case
                  of two numbers they are also used for right and bottom.
--(no)clip          clipping support, if margins are set     (false)
                  (not available for --xetex)
--(no)hires         using `%%HiResBoundingBox'               (false)
                  instead of `%%BoundingBox'
--(no)ini           use iniTeX variant of the TeX compiler   (false)
Expert options:
--restricted        turn on restricted mode                  (false)
--papersize <foo>   parameter for gs's -sPAPERSIZE=<foo>,
                  use only with older gs versions <7.32    ()
--resolution <xres>x<yres>                                   ()
--resolution <res>  pass argument to ghostscript's option -r
                  Example: --resolution 72
--bbox "<left> <bottom> <right> <top>"                       ()
                  override bounding box found by ghostscript
                  with origin at the lower left corner
--bbox-odd          Same as --bbox, but for odd pages only   ()
--bbox-even         Same as --bbox, but for even pages only  ()
--pdfversion <1.x> | auto | none
                  Set the PDF version to 1.x, 1 < x < 8.
                  If `auto' is given as value, then the
                  PDF version is taken from the header
                  of the input PDF file.
                  An empty value or `none' uses the
                  default of the TeX engine.               (auto)

Input file: If the name is `-', then the standard input is used and
the output file name must be explicitly given.
Examples:
pdfcrop --margins 10 input.pdf output.pdf
pdfcrop --margins '5 10 5 20' --clip input.pdf output.pdf
In case of errors:
Try option --verbose first to get more information.
In case of bugs:
Please, use option --debug for bug reports.

...>pdfcrop --debug a.pdf生产

...>pdfcrop --debug a.pdf
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
* Restricted mode: disabled
* Option `pdfversion': auto
* Perl executable: C:\Perl64\bin\perl.exe
* Perl version: v5.24.2
* Perl product: ActivePerl, build 2403
* Pointer size: 8
* Pipe support: yes
* Fork support: no
* OS name: MSWin32
* Arch name: MSWin32-x64-multi-thread
* System: miktex
* Not found (mgs): mgs.exe
* Found (mgs): C:\Program Files\MiKTeX 2.9\miktex\bin\x64\mgs.exe
* Autodetected ghostscript command: mgs
* Input file: a.pdf
* Output file: a-crop.pdf
* Margins: 0 0 0 0
* PDF header: %PDF-1.5
* Using PDF minor version: 5
* Running ghostscript for BoundingBox calculation ...
* Ghostscript call: mgs -sDEVICE=bbox -dBATCH -dNOPAUSE -c save pop -f a.pdf
* Cleanup
* Temporary files: tmp-pdfcrop-9720.tex
!!! Error: Cannot call ghostscript `mgs' (No such file or directory/The system cannot find the file specified)!

(由@Ulrike Fischer 建议)

为什么会发生此错误?

相关内容