How to Compress a PDF Without Losing Quality
Reduce PDF file size significantly using smart compression techniques — without visible quality loss. Free online tools and command-line methods.
AltoUnlockPDF Team
PDF Tools Expert
A 50MB PDF of a simple document is a common frustration — email servers block it, uploading takes forever, and sharing becomes a hassle. Smart compression can often reduce PDF size by 50–90% with no visible quality difference.
Understanding PDF File Size
PDF size comes from three main sources:
- Embedded images — photos, screenshots, logos (usually 70–95% of total file size)
- Embedded fonts — especially when font subsetting isn’t done correctly
- Page streams — content like text and vector graphics (typically very small)
This means most compression focuses on image optimization within the PDF.
Method 1: AltoUnlockPDF Compress Tool (Free, Online)
Our PDF Compression tool offers three quality presets:
- Web/Screen — maximum compression, ideal for web sharing and email
- Balanced — 60–70% size reduction with minimal visible quality loss
- Print Quality — light compression, preserves detail for professional printing
- Upload your PDF
- Select compression level
- Download the compressed PDF
Method 2: Ghostscript (Free, Most Powerful)
Ghostscript is a free command-line tool that gives the most control:
# Install
brew install ghostscript # macOS
sudo apt install ghostscript # Ubuntu
# Screen quality (~72 DPI images, smallest file)
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/screen \
-sOutputFile=compressed.pdf input.pdf
# Ebook quality (~150 DPI) — best balance
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/ebook \
-sOutputFile=compressed.pdf input.pdf
# Printer quality (~300 DPI) — light compression
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/printer \
-sOutputFile=compressed.pdf input.pdf
PDFSETTINGS levels:
/screen— 72 DPI, RGB, maximum compression/ebook— 150 DPI, very small, good for most uses/printer— 300 DPI, CMYK, suitable for printing/prepress— 300 DPI, preserves color profiles
Method 3: Python (pypdf2 / pikepdf)
import pikepdf
def compress_pdf(input_path, output_path, image_quality=80):
with pikepdf.Pdf.open(input_path) as pdf:
# Compress all embedded images
for page in pdf.pages:
for name, obj in page.images.items():
image = pikepdf.PdfImage(obj)
# Re-encode with JPEG compression
obj.write(
image.as_pil_image().tobytes('jpeg', quality=image_quality),
filter=pikepdf.Name('/DCTDecode')
)
pdf.save(output_path, compress_streams=True)
original_size = os.path.getsize(input_path)
compressed_size = os.path.getsize(output_path)
reduction = (1 - compressed_size / original_size) * 100
print(f"Reduced by {reduction:.1f}%: {original_size/1e6:.1f}MB → {compressed_size/1e6:.1f}MB")
pip install pikepdf
Method 4: Adobe Acrobat (Free Online Tier)
Adobe Acrobat online has a free compress tool with a clean slider interface. Free tier: limited daily compressions. Best for occasional use without installing software.
Typical Compression Results
| PDF Type | Before | After (/ebook) | Reduction |
|---|---|---|---|
| Scanned document | 8 MB | 1.2 MB | 85% |
| Photo-heavy report | 45 MB | 6 MB | 87% |
| Text-only document | 500 KB | 380 KB | 24% |
| Presentation | 22 MB | 4 MB | 82% |
| Mixed content | 12 MB | 2.5 MB | 79% |
Text-only PDFs are already very small — compression savings are mostly seen in image-heavy documents.
When Not to Compress
Avoid heavy compression when:
- Printing professionally — you need 300 DPI minimum
- Archiving legal documents — keep the original quality
- Documents with fine text or small print — 72 DPI makes it unreadable
- Sending to printers — most require
/prepressor uncompressed originals
Reducing File Size Without Image Compression
Other PDF optimization techniques:
-
Remove metadata:
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFastWebView=true -sOutputFile=clean.pdf input.pdf -
Flatten form fields: After filling a form, flatten it to remove the interactive layer (significant size reduction)
-
Remove embedded fonts (text-only docs): If system fonts are available, font embedding isn’t necessary
-
Remove hidden layers and annotations: These add to file size with no visible benefit
-
Optimize for web (Fast Web View/linearize): Enables page-by-page loading — doesn’t reduce size but improves perceived performance
For batch processing large collections, OCRmyPDF combines OCR and optimization in one command: ocrmypdf --optimize 3 input.pdf output.pdf
Related Articles
How to Add a Watermark to a PDF for Free
Add text or image watermarks to PDF documents using free online tools, Python, and desktop software — for branding, drafts, and confidentiality.
Read Article
How to Fill Out a PDF Form Online for Free (No Adobe Required)
Fill, sign, and save interactive PDF forms using free online tools — no Adobe Acrobat Pro or special software needed.
Read Article
How to Merge PDF Files for Free: 6 Easy Methods
Combine multiple PDF documents into one file using free online tools, desktop apps, and Python scripts — no Adobe Acrobat Pro required.
Read Article