跳到正文

PDF 转灰度

把彩色文档转为灰度,同时保持文字可搜索。

在你的设备上处理

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

这款工具的作用

There is no way to recolour a PDF's vector content inside a browser - the colour lives in every content stream, in whichever of five colour spaces the producer chose. So this tool says plainly how it works: each page is re-rendered in grey and the document is rebuilt from the resulting images. The pages stop being vector as a result. The words do not stop being words: the text is read out first and drawn back invisibly over each image, so the document is still selectable and searchable.

The usual reason is printing. Colour pages cost several times what grey ones do on most office and copy-shop tariffs, and many print accounting systems bill by what the file contains rather than by what the driver was set to. It is also a straightforward way to shrink a colour scan.

工作原理

  1. Drop the PDF onto this page. Files up to 300 MB are accepted.
  2. Set the resolution. 150 dpi is the default and reads well on screen; raise it towards 300 dpi for a document that will be printed and examined closely.
  3. Leave Keep text searchable on unless you have a reason not to - it costs a little size and keeps the document usable.
  4. Adjust the JPEG quality under advanced options if the default of 82 per cent is softer or larger than you want.
  5. Press Convert to grayscale. Progress shows which page is being rendered, and the result reports the resolution used.

The conversion uses Rec. 709 luma rather than the average of the red, green and blue channels. The eye is roughly three times more sensitive to green than to red and ten times more than to blue, so averaging makes a saturated red and a saturated blue come out as the same middle grey when one should be clearly darker. Weighting the channels the way vision does keeps coloured text, chart series and highlighted rows distinguishable after the colour is gone.

Keeping the text searchable is what separates this from printing to an image. Before any page is replaced, PDF.js extracts every text run with its position and size; those runs are then drawn over the finished image in an invisible rendering mode. You can select a paragraph, search for a phrase and copy a table out of the result, even though what you are looking at is a picture.

The file will not always get smaller. A colour scan usually shrinks substantially, because three channels become one and the JPEG has less to encode. A text document made of vector glyphs frequently grows, sometimes several times over, because a page of crisp type is cheaper to store as instructions than as a picture of itself. If your goal is size rather than colour, Compress PDF is the tool to reach for.

Because the pages are rebuilt from images, what sits on top of them does not survive: links stop being clickable, form fields stop being fillable, and comments, highlights and stamps are gone rather than drawn in. If you need the marks kept as marks, flatten the document first and convert afterwards.

Rendering happens on your device with PDF.js and a canvas, and the rebuild with pdf-lib - both in Web Workers, neither over a network. This is the heaviest tool in the category on a large file, and it is still local: a 300-page colour report is rendered page by page in your own browser.

这款工具做不到的事

  • The output is images, not vector pages. Zooming in far enough shows the pixels, and the type is no longer infinitely sharp.
  • A text-heavy document can come out larger than the original, because a page of type stores more cheaply as instructions than as a picture.
  • Links, form fields and annotations are not carried over, since each page is replaced by an image of itself.

常见问题

为什么要转换文件,而不是在打印对话框里勾选灰度?
因为打印对话框只影响那一台机器上的那一次打印。复印店、共用打印机,或者打开文件的同事,都会各自做决定,而且很多打印计费系统只要文件里含颜色就按彩色计费,不管驱动怎么设置。把文档本身转换掉,就一次性了结了。
画质会损失多少?
颜色会永久消失,页面会变成你所选分辨率的图像。150 dpi 在屏幕上阅读毫无问题、打印也够用;300 dpi 是打印质量,但文件大约会大四倍。两种情况下文字层都会保留。
文件会变小吗?
彩色扫描件通常会小很多。文本为主的文档反而常常变大,因为把文字画进 JPEG 比描出这些文字的指令更占空间。两种结果都会以转换前后的大小显示出来,所以如果和你想的不一样,还能把原件留着。
转换后还能搜索和选中文字吗?
只要「保持文字可搜索」是开的,就可以。会在替换页面之前先取出文字,再以不可见的方式重新画到图像之上,所以选中、搜索和复制都照常可用。如果原件本来就是没有文字层的扫描件,就没有东西可保留——请先运行「PDF 转文字(OCR)」。
文档会被上传去渲染吗?
不会。每一页都由 PDF.js 在你自己的浏览器里画到画布上,再由 Web Worker 中的 pdf-lib 重新组合。什么都不会发送,这也意味着速度取决于你的设备,而不是某处的排队。

相关工具