Currently I use TeXWorks or WinEdt to generate my PDF then open a command window and execute the following to compress the file:

>gswin64c.exe -sDEVICE=pdfwrite -dMaxSubsetPct=100 -dPDFSETTINGS=/ebook -sOutputFile="file_out.pdf" -dNOPAUSE -dBATCH "file.pdf"

Is there a way to automatically include this into the build PDF functions of either TeXWorks or WinEdt? It's a trivial extra step, but one I would like to omit.


This is quite simple in WinEdt.

I'm assuming you have the latest version installed (9.0) and you're using pdflatex for compiling.

Go to "Options" -> "Options Interface" -> "Advanced Configuration" -> "Compile Macros" and double-click the "PDFLaTeX" item:

enter image description here

A local copy of PDFLaTeX.edt gets opened. In this file, after the line


add the following lines

    !`WinExe('','gswin64c.exe -sDEVICE=pdfwrite -dMaxSubsetPct=100 -dPDFSETTINGS=/ebook -sOutputFile="%N_out.pdf" -dNOPAUSE -dBATCH "%N.pdf"','%P','',011100);`);

and then save the file.

Next time you compile a file with pdflatex, you will have your file.pdf and the compressed file_out.pdf in the same directory.

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.