e-gineering / gs-docker-pdf-compress

Compress PDF files using docker and ghostscript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gs-docker-pdf-compress

A simple Docker approach to compressing PDF files.

Build the docker image

docker build -t my-ghostscript .

Docker run method

Run ghostscript to compress the input file

docker run --rm -v <absolute path to directory housing input PDF>:/data my-ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/data/output.pdf /data/<input PDF filename>

Example:

docker run --rm -v /home/darrow:/data my-ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/data/output.pdf /data/eg_website_proof_v2.pdf

Script method

Run the compress-pdf.ps1 or compress-pdf.sh files if you want a simpler interface.

./compress-pdf.sh <directory with input file> input.pdf out.pdf

.\compress-pdf.ps1 <directory with input file> input.pdf out.pdf

About

Compress PDF files using docker and ghostscript

License:Apache License 2.0


Languages

Language:PowerShell 48.1%Language:Shell 45.8%Language:Dockerfile 6.2%