Want to compress your pdf files ?
source link: https://dev.to/burakcank/want-to-compress-your-pdf-files-5ff9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Are you tired of scanning images and trying to shrink them under 25 mbs just so you can send them via email ? Look no further, I am here to save you from this trouble. (that kinda rhymed.)
This basic shell script uses ghostscript to compress your scanned pdfs significantly. Just yesterday I scanned 100 pages of documents and it was over 90 mbs. I searched for a way to compress them under 25 mbs and voila. Here I was with only 6 mbs of pdfs. Much wow. Such compression.
Why we need it,
- No need to go online. Especially no need to upload company top-secret documents to any website you see on the Internet.
- Possible huge compression without notable loss.
./shrinkpdf.sh in.pdf out.pdf
Don't forget to install ghostscript.
If you are in a situation exactly like me where there are 100 pdf files under one folder that you want to compress altogether, a simple for loop will suffice.
import os import subprocess import sys infolder = sys.argv outfolder = "compressed_" + infolder os.mkdir(outfolder) for f in os.listdir(infolder): subprocess.run(["./shrinkpdf.sh", os.path.join(infolder, f), os.path.join(outfolder, f)])
Run this python script,
python shrink.py pdfs/
and all of your pdfs will be put under compressed_pdfs/.
All the relevant details and more, inside. I humbly wanted to let you know such a useful tool exists.
Aggregate valuable and interesting links.
Joyk means Joy of geeK