文件格式任意转换助手Transfer Any File

离线 · 无上传 · 浏览器本地完成Offline · no uploads · runs in the browser

HTML 转 PDF——按 A4 逐页切片,脚本不执行、外链不下载HTML to PDF as A4 slices — scripts and remote assets out

这条路有两层保护和一个取舍。保护一是净化:文档先过 DOMPurify(保留 head 与 <style>,移除脚本),再在隐藏的 iframe 里渲染,而 iframe 的 sandbox 只给 allow-same-origin——脚本没有执行余地。保护二是离线:净化会保留远程 URL,所以渲染前还有一道把远程引用剥掉的步骤,一张远程图不会把「不联网」这条承诺破掉。取舍是产出形态:结果是渲染出来的位图按 A4 切片,页面里没有文字层,所以搜索、复制、朗读都拿不到文字。这一条对本站所有「文档转 PDF」链路都成立。This route has two protections and one trade-off. The first is sanitisation: the document passes DOMPurify (keeping head and <style>, removing scripts) and is then rendered inside a hidden iframe whose sandbox grants allow-same-origin only, so a script has nowhere to run. The second is the offline promise: sanitising keeps remote URLs, so a further pass strips remote references before rendering — one remote <img> cannot break the no-network claim. The trade-off is what comes out: rendered pixels sliced onto A4, with no text layer, so search, copy and read-aloud find nothing. That holds for every document-to-PDF route here.

一批转换结果卡片,含文件名、体积与下载入口
一次混合批量,一个 ZIP 下载One mixed batch, one ZIP download

这条链路怎么走How the route runs

HTMLHTML PDFPDF

共 1 步,由扩展的路径搜索自动选出,中间产物不落盘。1 step, chosen by the extension's own path search; intermediate results never touch the disk.

会保留什么What carries over

  • 整份文档按 800 px 版心排版,高度全部保留并切成 A4(210 × 297 mm)逐页写入,不是一张拉长的单页图The whole document lays out at an 800 px measure and its full height is kept, sliced onto A4 pages (210 × 297 mm) rather than stretched into one long page
  • 文档自己的 CSS 生效(head 与 <style> 都留着),同时通过沙箱 iframe 隔离,页面样式不会污染工作台The document’s own CSS applies (head and <style> are kept) inside a sandboxed iframe, so page styles cannot leak into the workbench
  • 切片是 PNG 且用 zlib 9 + Paeth:实测十个文档形状里它每一份都比 FAST 档小 1%–8%,文字与数据页比 JPEG 切片小 13%–31%Slices are PNG at zlib level 9 with a Paeth predictor: across the ten measured document shapes it beat the FAST level every time by 1%–8%, and text and data pages came out 13%–31% smaller than a JPEG slice
  • 图片与字体落定后才截图:先等加载,必要时再停 100 ms 让布局落定(只在真有图片、字体或动效的文档上等)Images and fonts settle before capture: the loader waits, and where a document genuinely has images, fonts or motion it pauses another 100 ms for layout
  • 取消以「一页」为粒度:每切一页检查一次中断,两个画布在退出时都会释放Cancellation has page granularity: the abort signal is checked before every slice and both canvases are released on the way out

如实说明的限制What it does not do

  • 没有文字层:PDF 里的字是画出来的,搜索、复制、屏幕阅读器都取不到内容There is no text layer: the characters are drawn, so search, copy and screen readers find nothing to work with
  • 远程引用在渲染前被剥掉,剥空之后的引用与相对路径引用会换成虚线方框占位;只有浏览器真解得开的 data: / blob: 图片能进 PDF,解不开的 data: 与已撤销的 blob: 会在那处留空,远程图片、远程字体与远程 CSS 一律不下载Remote references are stripped before rendering, and what is left of them — the emptied reference, plus any relative path — is replaced by a dashed placeholder box; only a data: or blob: picture the browser can still decode reaches the PDF, one it cannot (a revoked blob:, an unreadable data:) leaves that position empty, and no remote image, font or stylesheet is ever downloaded
  • 长文档像素比会降:高度超过 2000 px 用 1.5 倍、超过 4000 px 用 1 倍,超长页的字不如短页锐利Long documents drop resolution: past 2000 px of height the ratio is 1.5× and past 4000 px it is 1×, so very long pages are less crisp than short ones
  • 整页高度有上限:超出浏览器单次渲染能吃的长度时直接报错,而不是交出一份内容不全的 PDF——那种文档请拆成更短的部分分批转换Page height has a ceiling: past what the browser can render in one pass the conversion reports an error instead of delivering a PDF missing content — split such a document and convert the parts separately
  • 分页只看高度,不懂「章节起新页」;纸张固定 A4 竖版,不能选横版或其它尺寸Pagination only measures height and does not understand “start a new page per chapter”; the paper is fixed portrait A4 with no size or orientation choice

实操提示Working with it

  • 目标是 PDF 时输出参数面板不出现(那是为图片准备的),DPI 只在来源是 PDF 时才有意义The output panel is not offered for a PDF target (it belongs to image targets), and DPI matters only when the source is a PDF
  • 单个文件 100 MB、一批最多 200 个;文档在 10 秒内没加载完只报该文件超时,批次里其余继续100 MB per file and up to 200 files per batch; a document that never finishes loading inside 10 seconds reports its own timeout while the batch continues

常见问题Questions people actually ask

为什么 PDF 里选不中文字?Why can I not select the text in the PDF?

因为产物是渲染出来的位图。本站的所有 PDF 输出都走渲染这条路(HTML 是其中唯一能排版的中间格式),没有文字层生成路径;要可检索的文字,就交付 HTML、Markdown 或 Word。Because the artifact is rendered pixels. Every PDF this tool emits goes through that rendering path — HTML is its only typesetting intermediate — and there is no text-layer generator to call. For searchable text, deliver HTML, Markdown or Word instead.

为什么图片不见了?Why did the images vanish?

远程引用在渲染前被剥掉,这是离线承诺的必要部分;而相对路径在渲染用的沙箱文档里指向的是扩展自己的包,不是你 HTML 旁边的那个目录。所以这两类引用统一换成虚线方框——位置留着,内容不猜;只有等克隆到一半才失败的图(浏览器解不开的 data:、已经撤销的 blob:)会在那处直接留空。想让图片进 PDF,把它内联成 data URI;这一轮有图片没拿到,结果卡片上会按张数写明。Remote references are stripped before rendering — that is what keeps the offline promise, and a relative path resolves inside the sandboxed document against the extension package, not the folder next to your HTML. Both shapes therefore become a dashed placeholder box: the position is kept, the content is not guessed. Only a picture that fails later, while the clone is being built — a data: the browser will not decode, a blob: already revoked — leaves that position empty. Inline a picture as a data URI to get it into the PDF, and the result card counts how many positions were affected.

能控制纸张大小或分页位置吗?Can I choose the paper size or where pages break?

不能:A4 竖版、按高度切。需要精确分页位置时,在源 HTML 里控制块的高度与间距(比如给章节留出足够的块),或转成 PDF 后在 PDF 编辑器里重排。No: portrait A4, sliced by height. To influence where a break lands, control block heights and spacing in the source HTML (give a section enough vertical mass), or re-impose the PDF afterwards in a PDF editor.

不需要账号,也不需要联网:装好扩展后点图标,在新标签页里打开工作台,文件从磁盘直接选。No account and no network: install the extension, click its icon, and the workbench opens in a new tab reading straight off your disk.