Error in Converting PDF to PostScript with GhostScript, Access is denied Unable to open command line file _.at

StackOverflow https://stackoverflow.com/questions/1711146

Question

I installed ghostscript and updated the appropriate path variables ... however, I'm getting an error when I try to execute this command:

C:\PROGRA~1\gs\gs8.64\lib>pdf2ps mydocument.pdf mydocument.ps
Access is denied.
Unable to open command line file _.at

Is this the right command? Did I miss some configuration or path setting? Otherwise, is there a sane method of doing this conversion?

Was it helpful?

Solution

Access is denied suggest something to do with access to paths etc. I'd suggest rechecking the folder permission (although I'm sure you've done that). Also, you might want to try running the gswin32c.exe instead of the pdf2ps to see if you still get the error, you might get something a little more specific.

gswin32c.exe ^
  -dNOPAUSE ^ 
  -dBATCH ^
  -sDEVICE=pswrite ^
  -sOutputFile=mydocument.ps ^
   mydocument.pdf

OTHER TIPS

Using pdf2ps runs a batch file, really named pdf2ps.bat or pdf2ps.cmd. You can easily look up and understand its "source code". If you do, you'll see it tries to write some of its commandline options into a temporary file named _.at, in order to overcome the 128 character limit for DOS/cmd commandline length that exist on some Win/DOS platforms.

Since you are invoking pdf2ps from the %programs% directory where Ghostscript is installed, you don't seem to be using an account that is permitted to write stuff in there. :-)

With Ghostscript version gs9.10 the method pswrite didn't worked for me instead I tried using ps2write instead, and it worked for me, so the command worked for me is as below:

gswin32c.exe ^
  -dNOPAUSE ^ 
  -dBATCH ^
  -sDEVICE=ps2write ^
  -sOutputFile=mydocument.ps ^
   mydocument.pdf

and if this thing doesn't even works, then one can do this : try getting help by typing gswin32c.exe -h and then it will list all the available devices as shown below:

Default output device: display
Available devices:
   bbox bit bitcmyk bitrgb bj10e bj200 bjc600 bjc800 bmp16 bmp16m bmp256
   bmp32b bmpgray bmpmono bmpsep1 bmpsep8 cdeskjet cdj550 cdjcolor cdjmono
   cp50 declj250 deskjet devicen display djet500 djet500c eps9high eps9mid
   epson epsonc epswrite ibmpro ijs inkcov jetp3852 jpeg jpegcmyk jpeggray
   laserjet lbp8 lj250 ljet2p ljet3 ljet3d ljet4 ljet4d ljetplus m8510
   mswindll mswinpr2 necp6 nullpage pamcmyk32 pamcmyk4 pbm pbmraw pcx16
   pcx24b pcx256 pcxcmyk pcxgray pcxmono pdfwrite pgm pgmraw pgnm pgnmraw pj
   pjxl pjxl300 pkmraw plan planc plang plank planm plib plibc plibg plibk
   plibm png16 png16m png256 pngalpha pnggray pngmono pngmonod pnm pnmcmyk
   pnmraw ppm ppmraw **ps2write** psdcmyk psdrgb pxlcolor pxlmono r4081 spotcmyk
   st800 stcolor svg t4693d2 t4693d4 t4693d8 tek4696 tiff12nc tiff24nc
   tiff32nc tiff48nc tiff64nc tiffcrle tiffg3 tiffg32d tiffg4 tiffgray
   tifflzw tiffpack tiffscaled tiffscaled24 tiffscaled32 tiffscaled4
   tiffscaled8 tiffsep tiffsep1 txtwrite uniprint xpswrite
    Search path:
       C:\Program Files (x86)\gs\gs9.10\bin ;
       C:\Program Files (x86)\gs\gs9.10\lib ;
       C:\Program Files (x86)\gs\gs9.10\fonts ; %rom%Resource/Init/ ;
       %rom%lib/ ; c:/gs/gs9.10/Resource/Init ; c:/gs/gs9.10/lib ;
       c:/gs/gs9.10/Resource/Font ; c:/gs/fonts
    Initialization files are compiled into the executable.

As one can see only for the convenience only I have placed star(*) around the ps2write

use gimp open PDF file.

file -> export -> postscript.

If you want to use the gs executable you have to change the permissions.In the command prompt go to the location where gs executable is located and then use chmod 755 gs.

What you are doing is you are not writing command line at right place first you have to find out the instillation exe of ghostscript which is by default located at

  • c:\Program Files(x86)\gs\gs9.20(your ghostscript version)\bin\gswin32c.exe

there are two exe

  • 1- gswin32.exe
  • 2- gswin32c.exe

you have to use the second one because it execuit commmands at cmd not in gs cmd ok now what you have to do is write command like

 ...bin\gswin32c.exe -dNOPAUSE -dBATCH -sDEVICE=pswrite -sOutputFile=mydocument.ps   mydocument.pdf

note please check the file path correctly and one more thing file path like "D:\htmltopdf\document.ps" should be write as "D:/htmltopdf/document.ps" yes exactly replace backward slash with foreword slash only in file path and the command line is case sensitive also so be carefull with cases

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top