跳到正文

压缩 PDF

把 PDF 变小,绝不会变大。

在你的设备上处理

这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。

这款工具的作用

Two different things make a PDF smaller, and this tool does both in turn. The structural pass repacks the file's objects and recompresses its streams, which is lossless and usually saves 10 to 25 per cent on a document nobody has optimised before. The image pass re-encodes the pictures at a lower resolution, which is where the large reductions on a scan come from, and it is lossy. Both results are measured against the original, and if neither won you get your own file back rather than a slightly bigger one labelled compressed.

The trigger is almost always a limit somewhere else: a mail server that bounces attachments over 25 MB, an application portal that stops at 2 MB, or a 40 MB scanned contract that has to reach someone on a phone connection.

工作原理

  1. Drop the PDF onto this page. Files up to 300 MB are accepted.
  2. Pick a level. Light is structure only and changes nothing you can see; Balanced re-encodes images at 150 dpi; Strong drops to 100 dpi for getting a scan under an attachment limit.
  3. Choose Custom to set the numbers yourself - resolution between 72 and 300 dpi, quality between 30 and 95 per cent.
  4. Open advanced options if you also want the images turned grey, the metadata stripped, or a filled form flattened first. Each makes the file smaller.
  5. Press Compress. The result reports the size before and after, and how many pages were re-encoded.

The structural pass is qpdf rewriting the file with object streams, compressed cross-references and every flate stream recompressed at level 9. Nothing about the page content changes, so it always runs whatever level you picked. On a file that has already been through a good optimiser it saves nothing at all, which is a real outcome rather than a failure.

The image pass works by re-rendering. A browser cannot reach inside a PDF and re-encode the pictures in place, so every page is drawn at the resolution you chose and written back as a JPEG. That would normally cost you the text, so the text is read out with PDF.js first and drawn back over the images in an invisible layer, keeping words selectable and searchable. What this route cannot carry across is links, form fields and annotations - if you need those, use Light.

The rule this tool will not break is that it never hands back a bigger file. An already-optimised document, and one whose images are stored more efficiently than a fresh JPEG of the same page, both genuinely come out larger. When that happens the original bytes are returned untouched and the result says the file was already optimised, because a compressor that grows your file and reports success is worse than no compressor.

Knowing where the size sits will save you a disappointment. In a scan it is the images, so Strong can take 40 MB to under 5 MB. In a text report it is the embedded fonts and the structure, so 10 to 20 per cent is a good result and re-encoding its few images changes very little.

Everything runs on your device. qpdf and PDF.js are compiled to WebAssembly and run in Web Workers, so a 300 MB scan is processed without a byte being sent anywhere.

这款工具做不到的事

  • Anything above Light re-encodes the images, which is lossy - fine print in a scan softens, and the loss cannot be undone from the output file.
  • A document that has already been optimised may not shrink at all. In that case the original is returned unchanged and the result says so.
  • When the image pass wins, the pages are rebuilt from pictures, so links, form fields and annotations are not carried over. The text layer is, invisibly.

常见问题

我的文件能小多少?
取决于里面是什么。扫描件是图像,用「均衡」常能压到四分之一,用「较强」能压到十分之一以内。文本文档由字体和结构组成,无损处理能减少 10 到 25 个百分点,此外可压的空间不多。结果会同时显示前后两个数字,方便你判断要不要试更强的档位。
文档看起来还正常吗?
「较轻」看起来完全一样,因为只改变文件结构。「均衡」会把图像以 150 dpi 重新编码,在屏幕上阅读毫无问题,打印也够用。「较强」的 100 dpi 在仔细看扫描件时能看出来,但阅读没有影响。删除原件前,先检查一页结果。
为什么我的文件一点都没变小?
因为它已经被优化过了。用现代软件导出的文件,或者之前压缩过的文件,已经没有可以再压的余地。这个工具不会把稍大一点的文件贴上「成功」标签返回,而是把原件还给你,并如实说明。
压缩会让文字无法搜索吗?
不会。执行图像处理时,会在替换页面之前先取出文字,再以不可见的方式重新画到图像之上,所以你仍然可以选中、搜索和复制。这条路径上会丢失的是链接、表单域和注释,这也是「较轻」档存在的原因。
文件会被上传去压缩吗?
不会。压缩在你的浏览器里完成,qpdf 和 PDF.js 以 WebAssembly 的形式运行在 Web Worker 中。打开开发者工具,切到网络面板再压缩点什么:没有任何外发请求,而且页面加载之后即使离线也能用。
要压到邮件限制以内,该用哪个档位?
先用「均衡」,看看显示的大小。如果还超,就试「较强」;如果仍不够,在高级选项里打开图像灰度化,对彩色扫描件通常还能再减掉三分之一左右。

相关工具