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

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

PDF 转 HTML——本地还原文字与链接,带页面分隔PDF to HTML locally — text and links, page breaks kept

这条是 PDF → 纯文本的「更值得后续加工」版本:同样只吃文字层,但产出的是带段落、标题与超链接的 HTML,而不是一个扁平的 .txt。标题有两个来源:PDF 自带的书签(大纲)按层级写成 `<h1>`–`<h6>`,前提是书签的文字与该行的文字「整行相等」;没有书签、或书签对不上的文档退回到几何判断——一行全大写、短于 80 字符的文字会被认成标题写成 `<h2>`,其余成段;同一页里落在同一基线上的文字拼回一行,段与段之间靠基线的纵向间距判断。这套判断是几何的,不是语义的,所以下面「丢弃项」里那条关于分栏与旋转文字的说明值得先读。This is the "worth keeping as a document" sibling of PDF to plain text: same text layer only, but the output has paragraphs, headings and hyperlinks instead of a flat .txt. Headings come from two places: the PDF’s own bookmarks (its outline) are written as `<h1>`–`<h6>` at their outline depth, provided the bookmark text equals the line it lands on — a whole line, not a prefix. With no outline, or nothing that matches, the route falls back to the geometric test: a short all-caps line under 80 characters becomes an `<h2>`, everything else becomes a paragraph; characters sitting on the same baseline are joined back into one line, and lines are split by how far apart their baselines are. That test is geometric, not semantic, which is why the column-and-rotated-text limit below is worth reading first.

左右对照的预览与编辑视图
左右对照预览,下载前直接改Preview side by side, edit before you download

这条链路怎么走How the route runs

PDFPDF HTMLHTML

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

会保留什么What carries over

  • 文字层按基线拼回行、按阅读顺序成段,pdf.js 在你自己机器上解析The text layer is rejoined into lines by baseline and into paragraphs in reading order, parsed by pdf.js on your own machine
  • 书签按层级写成 `<h1>`–`<h6>`(要求整行文字与书签一致);没有书签时,短而全大写的行升级为 `<h2>`,其余成 `<p>`;同一页的文字不会被打散成单字Bookmarks become `<h1>`–`<h6>` at their outline depth when the line equals the bookmark title; otherwise a short all-caps line is promoted to an `<h2>` and the rest become `<p>`, and text on a page is not shattered into single characters
  • 链接标注保留为 `<a>`,并且按协议白名单过滤——只放 https、mailto 与 tel,PDF 自带的 javascript: 与 data: 地址被剔除Link annotations survive as `<a>`, filtered by a scheme allowlist — https, mailto and tel pass, while javascript: and data: targets carried by the PDF are removed
  • 每页之间插入一条带 `page-break-after` 的分隔线,转成 Word 或 PDF 时这条边界仍然看得见A separator carrying `page-break-after` is placed between pages, so that boundary is still visible when the HTML later goes to Word or back to PDF
  • 产出的 HTML 自包含:内联样式、系统字体栈、`<title>` 用你自己的文件名,没有外部请求The HTML is self-contained: inline styles, a system font stack, a `<title>` taken from your own file name, and no external request

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

  • 扫描件、拍照件、图片型 PDF 提不出文字——没有 OCR,也不会替你猜Scans, photographs and image-only PDFs yield nothing — there is no OCR and no guesswork in its place
  • 版式不进 HTML:分栏、页眉页脚、字体、字号、颜色与表格线都会消失;PDF 里的表格只是排过版的字符Layout does not enter HTML: columns, headers and footers, fonts, sizes, colour and rules are gone; a table in a PDF is typeset characters, not structure
  • 行与行的判断只看纵坐标,所以跨栏排布、旋转 90° 的文字、以及同一基线上间距很大的两块文字可能被拼错或拆错Lines are decided on the vertical coordinate alone, so multi-column text, text rotated 90°, and two blocks sharing a baseline can be joined or split wrongly
  • PDF 内嵌图片不按对象导出,产物里没有 `<img>`;要页面图像请走 PDF → 图片Images embedded in the PDF are not exported as objects and there is no `<img>` in the output; for page imagery take the PDF to image route
  • 因此 PDF → CSV / JSON / Excel 在界面上是置灰的,不是点了才报错(PDF 不携带表格结构,见 utils/core/conversion-policy.ts)That is why PDF → CSV / JSON / Excel is greyed out in the picker instead of failing after you click: a PDF carries no table structure (see utils/core/conversion-policy.ts)

实操提示Working with it

  • 同一份 PDF 还能直接转 Markdown(保留标题与段落层级)或纯文本,三者同源、取舍一致The same PDF can also go straight to Markdown, which keeps heading and paragraph hierarchy, or to plain text — three outputs from one source with the same trade-offs
  • 多份 PDF 可以一批处理,单个上限 100 MB,一批最多 200 个文件;单个文件失败只报该文件Several PDFs run in one batch, 100 MB per file and 200 files per run; one unreadable file reports only itself
  • 带密码或损坏的 PDF 会给出该文件的解析失败提示,不会静默产出空文档An encrypted or damaged PDF reports its own parse failure for that file rather than quietly producing an empty document

常见问题Questions people actually ask

转出来的 HTML 和原来的 PDF 长得一样吗?Will the HTML look like the original PDF?

不会,也不该期待。PDF 保存的是"这一页在哪个坐标画哪一笔",HTML 保存的是文档结构与文字;这条转换带走文字与链接,剩下的一律由浏览器排版决定。需要视觉一致就用 PDF → 图片,那才是逐页像素。No, and it would be wrong to expect it. A PDF stores which stroke is painted at which coordinate on a page; HTML stores structure and text. This route carries text and links, and the browser does the rest of the layout. For visual fidelity take PDF to image, which is page-by-page pixels.

为什么有的段落被拆成好几行?Why did some paragraphs break into several lines?

因为行边界是按基线纵坐标推断的:PDF 里每行文字的位置是绝对坐标,没有"这里是一段"的标记。跨栏、旋转文字或行距异常紧密的排版都会让推断出错。改法是回到导出 PDF 之前的源文件(Word / Markdown / HTML),那里真的有段落。Because line breaks are inferred from baseline coordinates: in a PDF every line sits at an absolute position with no marker saying "a paragraph ends here". Column layouts, rotated text and unusually tight leading all break that inference. The fix is the file the PDF was exported from (Word, Markdown, HTML), where paragraphs genuinely exist.

生成的 HTML 为什么没写语言标记?Why is there no language attribute in the generated HTML?

刻意不写。提取出的文字是文档自己的语言,给根元素标 `lang="en"` 会让读屏软件用错误的发音规则去读一份中文报告,所以这一版宁愿留空,也不做一个页面无法证实的断言。Deliberately absent. The extracted text is in whatever language the document is, and labelling the root `lang="en"` would make a screen reader apply English pronunciation rules to a Chinese report. This version leaves it unset rather than assert something the file cannot support.

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