Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ ClearHowGuide Private PDF Compressor

Private browser-based PDF compressor with Lossless, Balanced and Maximum compression modes.

Built and maintained by ClearHowGuide.

License: MIT Astro Processing WebAssembly


πŸš€ Live tool

Official live version:

https://clearhowguide.com/en/tools/pdf-compressor/

Full guide:

https://clearhowguide.com/en/files/compress-pdf-without-losing-quality/


πŸ“„ What it does

The ClearHowGuide Private PDF Compressor analyzes and compresses PDF files directly in the browser.

The current version provides three compression modes.

Lossless Optimize

Uses the ClearHowGuide Go/WebAssembly engine powered by pdfcpu.

Designed to:

  • preserve the original PDF structure;
  • avoid intentional image-quality reduction;
  • optimize PDF objects and resources;
  • validate the generated PDF;
  • preserve selectable text, links and interactive structure where supported.

Lossless compression may produce only a small reduction when the source PDF is already optimized.

Balanced

Uses browser-side page rasterization through the ClearHowGuide wise-pdf integration.

Current preset:

180 DPI
JPEG quality 82

It aims for strong file-size reduction while retaining high visual quality.

Because pages are rasterized, selectable text, links, forms, accessibility tags and other interactive PDF features may be lost.

Maximum Compression

Uses more aggressive browser-side rasterization.

Current preset:

120 DPI
JPEG quality 60

Designed for cases where reaching a smaller file size matters more than preserving original PDF structure.

Selectable text, links, forms and other interactive features are not preserved.


✨ Features

The current version includes:

  • drag-and-drop PDF selection;
  • standard file picker;
  • PDF analysis before compression;
  • page count;
  • image/resource information;
  • font/resource information;
  • compression recommendation;
  • Lossless Optimize mode;
  • Balanced mode;
  • Maximum Compression mode;
  • local browser-side processing;
  • Web Worker execution;
  • WebAssembly lossless engine;
  • cancellation support;
  • elapsed-time processing indicator;
  • result file-size comparison;
  • percentage reduction display;
  • PDF output validation;
  • compressed PDF preview;
  • previous/next page preview navigation;
  • downloadable compressed result;
  • reset and compress-again workflow;
  • large-file warning;
  • 200 MB current file-size limit;
  • responsive layout;
  • light/dark theme compatibility;
  • no PDF upload to ClearHowGuide;
  • no PDF upload to PocketBase;
  • no PDF upload to R2;
  • no remote compression server.

πŸ” Privacy promise

PDF data is processed locally in the browser.

The compressor does not need to send the selected PDF to:

  • ClearHowGuide;
  • PocketBase;
  • Cloudflare R2;
  • a compression API;
  • a third-party compression server.

The component does not intentionally persist PDF contents in:

  • localStorage;
  • sessionStorage;
  • IndexedDB;
  • cookies.

See PRIVACY.md.


🧠 Architecture

PdfCompressor.astro
        β”‚
        β”œβ”€β”€ PDF analysis / preview
        β”‚       ↓
        β”‚   PDF.js 6.2.108
        β”‚
        β”œβ”€β”€ Lossless Optimize
        β”‚       ↓
        β”‚   pdf-worker.js
        β”‚       ↓
        β”‚   wasm_exec.js
        β”‚       ↓
        β”‚   pdf-engine.wasm
        β”‚       ↓
        β”‚   Go + pdfcpu 0.15.0
        β”‚
        └── Balanced / Maximum
                ↓
            wise-pdf Web Worker
                ↓
            page rasterization
                ↓
            JPEG / PNG codecs
                ↓
            rebuilt PDF

πŸ§ͺ Compression presets

Mode Engine Current preset Structure
Lossless Go + pdfcpu WASM structural optimization best preservation
Balanced wise-pdf 180 DPI / JPEG 82 rasterized
Maximum wise-pdf 120 DPI / JPEG 60 rasterized

πŸ“Š Real test examples

Results depend heavily on the structure of the source PDF.

A ClearHowGuide V1 image-heavy test file:

Original:
~36.8 MB
100 pages

Balanced:
~21.0 MB

Maximum:
~8.14 MB

A smaller mixed-content test:

Original:
~1.07 MB

Lossless:
~967 KB

These examples are not guarantees. Some PDFs compress substantially; already optimized PDFs may shrink very little.


⚠️ Important limitations

Balanced and Maximum rebuild pages as images.

They may therefore remove or change:

  • selectable text;
  • searchable text;
  • hyperlinks;
  • form fields;
  • annotations;
  • document structure;
  • accessibility tags;
  • embedded interactive content.

Use Lossless when retaining document structure matters.

Always keep the original PDF.


πŸ›  Technology

The project uses:

  • Astro;
  • browser-native JavaScript;
  • Web Workers;
  • WebAssembly;
  • Go;
  • pdfcpu 0.15.0;
  • PDF.js / pdfjs-dist 6.2.108;
  • ClearHowGuide's vendored wise-pdf build;
  • @jsquash/jpeg;
  • @jsquash/oxipng.

πŸ“¦ Installation

This repository is distributed as source code rather than as a published npm package.

Copy the component and supporting files while preserving their relative paths.

See:

examples/basic-usage.mdx

Install dependencies:

npm install

Run repository checks:

npm run check

🧱 Rebuilding the Lossless WebAssembly engine

Go is required.

Run:

npm run build:wasm

The script compiles:

src/wasm/pdf-compressor/main.go

into:

public/tools/pdf-compressor/pdf-engine.wasm

and copies the matching Go WebAssembly runtime:

public/tools/pdf-compressor/wasm_exec.js

βœ… Run checks

Install:

npm install

Then:

npm run check

Or run the checks separately:

npm run check:structure
npm run check:privacy

The structure check verifies:

  • required source files;
  • required runtime files;
  • WebAssembly file header;
  • key compressor functionality markers;
  • the pinned SHA-256 of the vendored wise-pdf package.

The privacy check scans the published component and workers for browser-storage, network-upload and analytics-input patterns.


πŸ“ Repository structure

pdf-compressor/
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE/
β”‚   β”‚   β”œβ”€β”€ bug_report.yml
β”‚   β”‚   └── feature_request.yml
β”‚   └── pull_request_template.md
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ basic-usage.mdx
β”‚   └── hosted-embed.html
β”œβ”€β”€ public/
β”‚   └── tools/
β”‚       └── pdf-compressor/
β”‚           β”œβ”€β”€ pdf-engine.wasm
β”‚           β”œβ”€β”€ pdf-worker.js
β”‚           └── wasm_exec.js
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ build-pdf-compressor-wasm.sh
β”‚   β”œβ”€β”€ check-structure.mjs
β”‚   └── privacy-check.mjs
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   └── tools/
β”‚   β”‚       └── PdfCompressor.astro
β”‚   β”œβ”€β”€ wasm/
β”‚   β”‚   └── pdf-compressor/
β”‚   β”‚       β”œβ”€β”€ main.go
β”‚   β”‚       β”œβ”€β”€ go.mod
β”‚   β”‚       └── go.sum
β”‚   └── workers/
β”‚       └── wise-pdf.worker.js
β”œβ”€β”€ vendor/
β”‚   └── wise-pdf/
β”‚       β”œβ”€β”€ ecgear-wise-pdf-0.1.0-clearhowguide.1.tgz
β”‚       β”œβ”€β”€ CLEARHOWGUIDE_PATCH.diff
β”‚       β”œβ”€β”€ LICENSE
β”‚       β”œβ”€β”€ NOTICE
β”‚       └── PROVENANCE.md
β”œβ”€β”€ EMBEDDING.md
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CITATION.cff
β”œβ”€β”€ CODE_OF_CONDUCT.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ PRIVACY.md
β”œβ”€β”€ README.md
β”œβ”€β”€ SECURITY.md
β”œβ”€β”€ SUPPORT.md
β”œβ”€β”€ THIRD_PARTY_LICENSES.md
β”œβ”€β”€ astro.config.mjs
β”œβ”€β”€ package-lock.json
└── package.json

🌐 Embed on your website

The hosted ClearHowGuide Private PDF Compressor can be added to websites that allow HTML iframes.

No installation, API key or backend is required.

<iframe
  src="https://clearhowguide.com/en/tools/pdf-compressor/embed/"
  title="ClearHowGuide Private PDF Compressor"
  width="100%"
  height="1100"
  loading="lazy"
  style="display:block;width:100%;border:0;border-radius:16px;"
></iframe>

For the recommended responsive version with automatic height adjustment, see:

EMBEDDING.md

The hosted version remains maintained by ClearHowGuide and PDF processing remains local in the visitor's browser.

Live embed:

https://clearhowguide.com/en/tools/pdf-compressor/embed/


🀝 Contributing

Contributions are welcome.

Please read:

CONTRIBUTING.md

before opening a pull request.


πŸ›‘ Security

Do not publish security vulnerabilities or confidential PDF samples in public issues.

See:

SECURITY.md


πŸ’¬ Support

For usage questions and bug reports:

SUPPORT.md


πŸ“š Citation

Citation information is available in:

CITATION.cff


πŸ“œ License

ClearHowGuide-authored source code is released under the MIT License.

Third-party components retain their respective licenses.

See:


🌐 Used by

ClearHowGuide:

https://clearhowguide.com/en/tools/pdf-compressor/

Guide:

https://clearhowguide.com/en/files/compress-pdf-without-losing-quality/

About

Private browser-based PDF compressor with Lossless, Balanced and Maximum modes, built with Astro, Web Workers and WebAssembly.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages