PDF Tools April 3, 2026 · 7 min read

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.

How to Compress a PDF Without Losing Quality
AT

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:

  1. Embedded images — photos, screenshots, logos (usually 70–95% of total file size)
  2. Embedded fonts — especially when font subsetting isn’t done correctly
  3. 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
  1. Upload your PDF
  2. Select compression level
  3. 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
PDF file size being reduced with compression

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 TypeBeforeAfter (/ebook)Reduction
Scanned document8 MB1.2 MB85%
Photo-heavy report45 MB6 MB87%
Text-only document500 KB380 KB24%
Presentation22 MB4 MB82%
Mixed content12 MB2.5 MB79%

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 /prepress or uncompressed originals
PDF compression tool interface

Reducing File Size Without Image Compression

Other PDF optimization techniques:

  1. Remove metadata: gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFastWebView=true -sOutputFile=clean.pdf input.pdf

  2. Flatten form fields: After filling a form, flatten it to remove the interactive layer (significant size reduction)

  3. Remove embedded fonts (text-only docs): If system fonts are available, font embedding isn’t necessary

  4. Remove hidden layers and annotations: These add to file size with no visible benefit

  5. 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