4

My PDF file is corrupted, then after searching the web I found a good thread here. Since I hadn't gswin32c on my Windows 7 x86 system I installed it from here. Now I have it on my system and ran it now! :) But my problem is that how to use the commands written there as follows:

gswin32c.exe ^
  -o repaired.pdf ^
  -sDEVICE=pdfwrite ^
  -dPDFSETTINGS=/prepress ^
   corrupted.pdf

1 Answer 1

5

How do I use the following commands:

gswin32c.exe ^
  -o repaired.pdf ^
  -sDEVICE=pdfwrite ^
  -dPDFSETTINGS=/prepress ^
   corrupted.pdf

Note that the above is a single command. The ^ character is an escape character, allowing the command to be split across multiple lines (it is escaping the <eol> characters).

So it could be written as:

gswin32c.exe -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress corrupted.pdf

To run this command:

  1. Open a cmd shell

  2. Change directory to the location of the PDF file:

     cd c:\PathToMypdf
    
  3. Run the following command:

     c:\PathToGswin\gswin32c.exe -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress corrupted.pdf
    

Notes:

  • If PathToMypdf contains spaces then the directory needs to be quoted:

     cd "c:\PathToMypdf"
    
  • if PathToGswin contains spaces then the command needs to be quoted:

     "c:\PathToGswin\gswin32c.exe" -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress corrupted.pdf
    

C:\Program is not recognized as an internal or external command, operable program or batch file

My pdf file with the name p2.pdf is in this diretory: C:\Users\Me\Desktop\Attach.

And the gswin32c.exe is in this directory: C:\Program Files\gs\gs9.09\bin

When I run this command:

C:\Program Files\gs\gs9.09\bin\gswin32c.exe -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress p2.pdf

I get the following error "C:\Program" is not recognized as an internal or external command, operable program or batch file.

What part is wrong please?

You need to run the following commands:

cd C:\Users\Me\Desktop\Attach
"C:\Program Files\gs\gs9.09\bin\gswin32c.exe" -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress p2.pdf

Notes:

  • The "s are required because the path C:\Program Files\gs\gs9.09\bin\ contains spaces.
4
  • My pdf file with the name p2.pdf is in this path: C:\Users\Me\Desktop\Attach. And the gswin32c.exe is in this path: C:\Program Files\gs\gs9.09\bin When I run this command: C:\Users\Me\Desktop\Attach>C:\Program Files\gs\gs9.09\bin\gswin32c.exe -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress p2.pdf, the cmd says:_'C:\Program' is not recognized as an internal or external command, operable program or batch file._!! What part is wrong please?
    – Franky
    Apr 17, 2016 at 14:12
  • @franky Answer updated.
    – DavidPostill
    Apr 17, 2016 at 14:29
  • Thank you very much for your explanations. I made your reply an answer. But although it worked (with the message GPL Ghostscript 9.09: unrecoverable error, exit code 1), it couldn't recover my pdf properly. It yielded a bland repaird pdf file. :(
    – Franky
    Apr 18, 2016 at 5:04
  • @franky It looks like your PDF can't be recovered using gswin. You need to look for other recovery methods.
    – DavidPostill
    Apr 18, 2016 at 7:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .