Search code examples
windowscompressionghostscript

Failed attempt to compress pdf with ghostscript - Device 'pdfwrite' requires output file


I tried to compress a pdf-file with the following command:

gswin64c -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=test-compressed.pdf test.pdf

I am in the directory of test.pdf and I can also open it, but when I execute the command I get the following error, although the output file should be specified with -sOutputFile=test-compressed.pdf:

GPL Ghostscript 9.16: Device 'pdfwrite' requires an output file but no file was specified.
**** Unable to open the initial device, quitting.

Solution

  • I solved it myself: it doesn't work with PowerShell, whereas it works with cmd.exe .