离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser
TXT 转 WebP——离线、按 A4 分页、终点单次量化TXT to WebP offline — A4 pages, one lossy encode
这条链的形状和 TXT→JPG 完全一样,只有终点不同:`txt>html` + `html>pdf` + `pdf>webp`(三步,基线现读)。文本先包成等宽 `<pre>` 网页,在**固定 800 px 版心**(`utils/core/html-raster.ts:7` 的 `RENDER_WIDTH`)里排版成一张画布,`html>pdf` 再把它**按 210 mm 宽等比映射到 A4 纵向、每 297 mm 切一刀**(800 px 宽下约每 1131 px 一页),逐页作为 **PNG 无损切片**写进一份临时 PDF,最后由 pdf.js 把每页画到白底画布、`encodeCanvas` 编成 WebP。四点值得先说:一,**产出是一页一张的纸**(与 TXT→PNG 那张连续长图相对);二,**页数决定容器**——只有一页时是 `converted.webp`,两页以上打包成 `converted.zip`,成员按页码命名 `page-N.webp`;三,**整条链只量化一次**——中间那趟是 PNG 切片,质量与目标尺寸这些旋钮只作用在最后那一步;四,背景是白的(渲染器把 `backgroundColor` 写死为白色),文字图不谈透明。代价也照实说:`<pre>` **不折行**,800 px 版心里它只剩 **702 px 的文字区**(减去 body 左右内边距 64、`pre` 边框 2 与内边距 32,四个数都写死在 `utils/core/html-document.ts`),又是 `overflow-x: auto`,所以超出的行尾既不换行也不会被画进图里,宽度方向没有任何检查;高度方向有闸,排版超过 32768 px 时渲染那一步明确报 `errors.renderTooTall`(TXT→PDF 也是同一道闸,绕不开),也因此这份中间 PDF 排不到几百页,出图那一步的页数上限在这条链上碰不到。WebP 与 JPEG 的取舍在终点:同为有损,WebP 通常在同等观感下更小,但它是网页侧的通用格式而不是「哪里都能开」的那一个;要边缘锐利、或之后再从图里取字,请走 TXT→PNG。全程只有 storage 权限、不联网。The shape here is identical to TXT to JPG and only the endpoint differs: `txt>html` + `html>pdf` + `pdf>webp` — three steps, read live from the baseline. The text becomes a monospace `<pre>` page, laid out inside a **fixed 800 px measure** (`RENDER_WIDTH` at `utils/core/html-raster.ts:7`) into one canvas, which `html>pdf` **maps onto A4 portrait at 210 mm wide and cuts every 297 mm** — roughly one sheet per 1131 px of laid-out height at 800 px — writing each slice into a temporary PDF as a **lossless PNG**, and finally pdf.js draws every page onto a white canvas and `encodeCanvas` writes WebP. Four things to say first: the output is **one sheet per page** (against TXT to PNG’s single continuous image); **the page count picks the container** — a single page is `converted.webp`, two or more are packed into `converted.zip` with members named `page-N.webp`; **the chain quantises once** — the middle is PNG slices, and quality and target size act only on that last step; and the ground is white, because the renderer pins `backgroundColor` to white, so a text picture has no alpha talk either. The costs, plainly: `<pre>` **does not wrap**, and inside the 800 px measure it keeps only a **702 px text band** (the body’s 64 px of horizontal padding, then the `pre`’s own 2 px of border and 32 px of padding — all four numbers are hard-coded CSS in `utils/core/html-document.ts`), and being `overflow-x: auto` it neither reflows nor paints what runs past that, with nothing checking width; height is gated, past 32768 px of laid-out page the render step fails with `errors.renderTooTall` (TXT to PDF carries the same ceiling, no way around it), which is also why this intermediate PDF never reaches hundreds of pages and the image step’s page cap cannot be hit on this chain. WebP versus JPEG is an endpoint trade-off: both lossy, WebP usually smaller at comparable appearance, but it is a web-side format rather than the one that opens everywhere. For crisp edges, or if the words may be needed later, take TXT to PNG. All of it on the storage permission, with no network.
这条链路怎么走How the route runs
纯文本 (TXT)plain text (TXT) HTMLHTML PDFPDF WebPWebP
共 3 步,由扩展的路径搜索自动选出,中间产物不落盘。3 steps, chosen by the extension's own path search; intermediate results never touch the disk.
会保留什么What carries over
- 一页一张的纸:按 A4 切页,与 TXT→PNG 的连续长图相对One sheet per page, sliced on A4 — against TXT to PNG’s single continuous image
- 页数决定容器:单页给 `converted.webp`,两页以上打包成 `converted.zip`,成员按页码命名 `page-N.webp`The page count picks the container: one page is `converted.webp`, two or more are zipped as `converted.zip` with members named `page-N.webp`
- 整条链只量化一次:中间是 PNG 无损切片,质量与目标尺寸只作用在 WebP 终点The chain quantises once: the middle is lossless PNG slices, and quality and target size act only on the WebP endpoint
- 同等观感通常比 JPEG 更小,且同样是网页里能直接 `<img>` 用的格式Usually smaller than JPEG at comparable appearance, and still a format a web page can put straight into an `<img>`
- 高度有闸:超过 32768 px 明确报 `errors.renderTooTall`,不静默给你半份图Height is gated: past 32768 px the render step fails with `errors.renderTooTall` rather than returning half a document
- 一批最多 200 个文件、单个 100 MB,与其他路线共用同一道闸门Up to 200 files per batch and 100 MB each — the same gate every other route shares
如实说明的限制What it does not do
- `<pre>` 不折行:800 px 版心减去内边距后文字区实测 702 px,超出的行尾被裁掉而不是换行,宽度没有闸——请先拆短长行`<pre>` never wraps: the text band is 702 px inside the 800 px measure (the body’s 64, its own 2 of border and 32 of padding come off) and it is `overflow-x: auto`, so line ends past it are neither reflowed nor painted — break long lines first
- 产物是图片:字选不中、搜不到,也不能被朗读The artifact is an image: the words cannot be selected, searched or read aloud
- 有损终点:文字边缘会被量化,锐利度要求高就选 TXT→PNGA lossy endpoint: glyph edges get quantised, so choose TXT to PNG when crispness matters
- 超长受 32768 px 上限约束,TXT→PDF 同一道闸;这条链的中间 PDF 排不到几百页Very long text hits the 32768 px ceiling, shared with TXT to PDF, and this chain’s intermediate PDF never grows to hundreds of pages
- 通用性不如 JPEG:要发给不知支持面的接收端,先试 JPEGLess universal than JPEG: when the receiving side’s support is unknown, try JPEG first
实操提示Working with it
- 要连续长图且无损:TXT→PNG(两步、不套 PDF)For a continuous lossless image: TXT to PNG — two steps, no PDF inside
- 要一份多页文档:TXT→PDF,中间那份 PDF 就是终点For a multi-page document: TXT to PDF, where the intermediate PDF is the destination
- 要一页一张且最通用:TXT→JPG,同一条三步链,终点换成 JPEGFor one page per image with maximum reach: TXT to JPG, the same three-step chain ending in JPEG
常见问题Questions people actually ask
为什么不直接 TXT→PNG,还要多一层 PDF?Why not just TXT to PNG instead of going through a PDF?
因为这两条路给你的东西不同。要「一张连续长图且无损」,TXT→PNG 更短也更准;会绕这一圈 PDF,是为了拿到**按 A4 分页的一页一张**,以及一个可以有损、能按质量或目标尺寸压小体积的终点。两条路的排版与「长行不折行被裁掉」这个限制是完全相同的。Because they hand over different things. For a continuous lossless image, TXT to PNG is shorter and more honest; the detour through a PDF exists to get **one page per A4 sheet** and a lossy endpoint that can be tuned by quality or target size. Layout and the «long lines are clipped, not wrapped» limitation are identical on both.
WebP 还是 JPEG?WebP or JPEG?
都在同一条三步链的终点做一次性有损编码。经验取向是:同等观感下 WebP 通常更小、也是网页里能直接用的格式;JPEG 的通用性更好,遇到支持面不明的接收端更稳。文字边缘两者都会被量化,真要锐利就选 TXT→PNG。Both are a single lossy encode at the end of the same chain. As a rule of thumb: WebP is usually smaller at comparable appearance and drops straight into a web page, while JPEG wins on unknown recipients. Both quantise text edges, so take TXT to PNG when edges must stay sharp.
很长的文本能一次转完吗?Can very long text be converted in one go?
不能。排版高度超过 32768 px 时,渲染那一步会明确报「超出浏览器单次渲染上限」,要求拆短分批;TXT→PDF 用同一个渲染器、同一道闸。也因此这份中间 PDF 排不到几百页——出图那一步的页数上限在这条链上其实碰不到,别把它当成能撑住长文档的机制。No. Past 32768 px of laid-out height the render step fails with «longer than the browser can render in one pass» and asks you to split it; TXT to PDF uses the same renderer and the same gate. So the intermediate PDF never grows to hundreds of pages either — the image step’s page ceiling is unreachable on this chain, and should not be read as what keeps long documents alive.
不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.
从 Chrome 应用商店安装Install from the Chrome Web Store 安装步骤Install steps GitHub 源码Source on GitHub
要把它压到指定体积?Need it under a target size? The 图片压缩工具image compressor可以在浏览器里重编码 PNG / JPEG / WebP。 re-encodes PNG / JPEG / WebP in the browser.