/* 2026-12-04 性能:提前宣告关键脚本。app.js 原先只在 body 末尾出现, 浏览器要解析完整份 HTML 才会开始下载(首屏 HTML 约 35KB)。 preload 让下载与 HTML 解析并行,而 defer 语义不变(DOM 就绪后按序执行)。 */
EN

Compress PDF

Shrink a PDF either by lossless structure optimisation or by re-rendering each page as an image, with the trade-offs spelled out before you pick.

FAQ

Why did Keep text barely change the file size?

Because the file was already optimised upstream. Modern office suites pack objects and compress the cross-reference table on export, so a lossless repack can only clear a little redundancy - measured gain on such files is 0.0%, and turning object streams off actually makes them 93% larger. For a real reduction use Smaller size, accepting that text becomes an image.

Text is no longer selectable after compressing. Is the file broken?

No - you used Smaller size. That mode draws each page as a JPEG and rebuilds the PDF, so text is a bitmap from then on: no searching, copying or selecting, and OCR cannot recover it either. Use Keep text when searchability matters, accepting a smaller saving.

Can it hit a target size, say under 2MB?

The tool offers fixed levels (96/150/300 DPI and three quality settings) rather than solving for a target size. To go smaller, pick 96 DPI with Small quality first, then look at the result; if it still misses, the images inside are simply too large and need their own downscaling.

Which mode suits a scanned document?

Smaller size. A scan is one large image per page, so lossless does almost nothing. Re-rendering at 150 DPI with Standard quality measured 501 KB down to 328 KB (35% smaller) on a 300 DPI scan, and 96 DPI with Small quality reached 173 KB (66% smaller). The text was never searchable, so nothing extra is lost.

Is the file uploaded to a server?

No. Parsing, repacking and re-rendering all happen in your browser, it works offline, and there is no page or usage limit.

About this tool

Shrinks a PDF. Two very different methods live here, with different costs, so they are two explicit buttons rather than one vague Compress action.

Keep text means structural optimisation. Objects are repacked and the cross-reference table is folded into object streams; not a byte of page content changes. Text stays searchable, copyable and selectable, images are not re-encoded, and quality loss is zero.

How much this saves depends on how clean the source file already was. Measured: resaving an already-optimised PDF with the same library changed its size by 0.0%, and turning object streams off made the same file 93% larger. In other words, whether the PDF was optimised upstream decides the gain. Files exported by older office suites or some scanner drivers often carry unreferenced objects and redundant structure and can drop 5-15%; modern exporters are already near the floor.

Smaller size means re-rendering. Each page is drawn as a JPEG and placed back into a new PDF at the original page size. The principle is print-to-PDF and it works best on high-resolution scans and photos. Measured on a 300 DPI, two-page, 501 KB scan: 150 DPI with Standard quality gave 328 KB (35% smaller), and 96 DPI with Small quality gave 173 KB (66% smaller).

The cost has to be stated plainly: text becomes a bitmap and can no longer be searched, copied or selected, and OCR cannot recover it either. Vector lines and glyph edges are rasterised again at the chosen resolution - 300 DPI is indistinguishable, 96 DPI softens when zoomed. Use this for scans, phone photos, image-heavy material, and anything that only has to be looked at.

How to choose:

  • Keep it editable - use Keep text. Smaller savings, zero content loss.
  • It just will not fit in an email - use Smaller size with 150 DPI and Standard quality.
  • Printing or archiving - Smaller size with 300 DPI and High, which still beats the original whenever the file carries redundant large images.

Why some files refuse to shrink. Two real cases:

  • The images are already compressed: a six-page PDF that reuses one 150 DPI image on every page weighs only 42 KB, and re-rendering must store a copy per page, which measured 212 KB (+409%). An eight-page text document going from 9 KB to 1.7 MB is the same story - text becomes a high-resolution bitmap and takes more room than the original.
  • The file was optimised upstream: lossless has nothing left to remove, so the gain is zero.

In both cases the tool never hands you a bigger file: if the result would grow, it says so and offers no download. The rule of thumb is simple - small file, many pages, mostly text means re-rendering will not help.

Limits: a password-protected PDF must be unlocked first, because its content streams stay encrypted and repacking produces a file that will not open; documents with many pages need a lot of memory when re-rendering, so lower the resolution or work in batches.

Everything runs locally in your browser and nothing is uploaded. These files are usually contracts, invoices and CVs, which should not be handed to a third-party server in the first place.