HTML 转 PDF
把保存的网页或文本文件转换为 PDF。
这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。
这款工具的作用
This takes a saved .html or .htm file, or a plain .txt file, and lays its content out as a PDF. Headings, paragraphs, lists, tables and links are read from the document's structure and re-flowed onto the paper you choose. CSS is not executed, so the result reads correctly and does not look identical to the page in a browser. There is no field for a web address, and that is a decision rather than an omission: fetching a page for you would mean an outbound request from a tool that promises none.
Use it on a page you have already saved: an article kept for offline reading, a receipt or booking confirmation a site would only show you in the browser, documentation you want on paper, or an export from a tool that writes HTML and nothing else.
工作原理
- Save the page first. In any desktop browser, press Ctrl+S or Command+S and choose Web page, HTML only - the complete option saves a folder of assets this tool does not need.
- Drop the .html file onto this page. Plain .txt files work too, up to 20 files at a time.
- Choose the paper size, orientation and margins. Wide margins suit anything you intend to annotate by hand.
- Leave keep hyperlinks on so the page's links stay clickable in the PDF.
- Turn on page numbers for anything you plan to print and hand round.
- Press Convert and the PDF downloads.
The page is re-flowed from its structure, not rendered. A browser turns HTML into a picture by executing CSS - float, flex, grid, absolute positioning, media queries, web fonts - and shipping a layout engine into a browser tab to do that a second time is not a small addition. Instead the document is read as headings, paragraphs, lists, tables and links, and set with the same typography as every other conversion here. Two columns become one, and the article you wanted comes out readable.
That trade has a side effect people tend to like. Navigation, banners and sidebars are flattened into the flow along with everything else, so they arrive as plain lists and paragraphs rather than as furniture down the edge of the page. This is not reader-mode extraction and does not claim to be - text that was decoration is still text - but the article stops being a narrow column squeezed between two others.
Images are not embedded. A saved .html file usually points at its pictures rather than containing them, and going out to fetch them would be exactly the outbound request this tool exists to avoid. Text, tables, lists and links come through; pictures do not, including ones written into the file as data URIs. If the pictures are the point, save them separately and use Images to PDF.
The file is treated as hostile. A saved web page can carry script tags, inline event handlers and javascript: links, and all three are stripped in the parser before anything reaches the layout engine. Nothing in the page runs, and no link that ends up in the PDF can execute anything.
The missing URL box is worth one more sentence. To fetch a page for you, this site would have to make the request itself or route it through a proxy, and either way somebody's server learns which page you were reading. For a tool whose whole claim is that your document never leaves your device, that is not a trade worth making. Saving the page yourself takes one keystroke and keeps the request in your own browser, where it already was.
这款工具做不到的事
- CSS is not executed, so colours, columns, positioning and web fonts are lost. The page is re-flowed as text, tables and lists.
- There is no URL field. Save the page to a file first; fetching it here would mean an outbound request on your behalf.
- Images are not embedded, including ones written into the file as data URIs. Text, tables and links come through.
常见问题
- 我能粘贴一个网址而不是文件吗?
- 不能,而且这是有意省略的,不是没人来得及做的功能。去获取页面就意味着本站点、或中间的某个 CORS 代理替你发出请求——这会告诉某人的服务器你正在读哪一页,也会破坏这款工具做出的唯一承诺。请改用 Ctrl+S 保存页面,再把文件拖到这里。
- 为什么 PDF 看起来不像网页?
- 因为样式表不会被执行。读取的是文档的结构——标题、段落、列表、表格、链接——并改用本站点自己的排版方式来布局。颜色、分栏、定位和网页字体都不会保留。你得到的是这个页面的内容,可读地排在你选择的纸张上。
- 页面上的图片会保留吗?
- 不会。图像不会被嵌入,因为保存的 .html 文件通常是引用它的图片,而不是包含它们,而去获取它们就意味着一次向外的请求。文本、表格、列表和链接都会转换;图片会被略去,包括那些以 data URI 形式写入文件的。
- 我该怎样保存网页才能转换它?
- 在 Windows 上按 Ctrl+S,在 Mac 上按 Command+S,并选择「网页,仅 HTML」而不是「完整」——「完整」选项会写出一个这款工具用不上的素材文件夹。在手机上,到浏览器的分享菜单里找「另存为文件」或「下载」选项。然后把保存好的文件拖到这个页面上。
- 关于这个页面的任何信息会被发到什么地方吗?
- 不会。文件完全在你的浏览器中解码、解析和排版,而且这里没有网址输入框,正是为了绝不替你发出任何请求。这个页面唯一会去获取的东西是 Noto 字体,来自本站点自己的源,而且只有在开启 Unicode 嵌入时才会。